Question
How to enable remote access to a MySQL/MariaDB database server in Plesk?
Answer
Warning: After enabling the access, all MySQL/MariaDB connections will be unencrypted. To make them encrypted, an SSL certificate is required. For that and additional steps check this link: https://dev.mysql.com/doc/refman/5.7/en/using-encrypted-connections.html#using-encrypted-connections-server-side-configuration
Note: Make sure that MySQL/MariaDB port is not blocked by a firewall: How to open all ports on local server needed by Plesk automatically?
By default, Plesk administrator does not have remote access. It is recommended to create a new user that will be used for the remote connection. Though user admin
can be used, too.
In order to enable remote access to a MySQL/MariaDB server follow the instructions below:
Plesk Obsidian for Linux:
-
Go to Tools & Settings > Database Servers > Settings > click on the Local MySQL Settings link:
-
Select the Allow local MySQL server to accept external connections checkbox and click OK to apply changes:
Allow remote access to MySQL/MariaDB database server in Plesk for Linux and Plesk for Windows for a specific user:
-
Go to Subscriptions > example.com > Databases > User Management > example_db_user.
-
Make sure that the Access control option is set to Allow remote connections from any host or to Allow remote connections from:
-
Open the MySQL/MariaDB configuration file in any text editor. The location of this file is:
-
For Linux:
-
for CentOS/RHEL-based distributions:
/etc/my.cnf
-
for Debian/Ubuntu-based distributions:
/etc/mysql/my.cnf
-
-
For Windows:
%plesk_dir%DatabasesMySQLmy.ini
-
-
Change/add
bind-address
parameter to:bind-address = 0.0.0.0
0.0.0.0 means every IP address on the server. If it is required to bind to a specific IP address, specify this particular IP instead of 0.0.0.0
Note: Make sure that
skip-networking
parameter is not defined in MySQL/MariaDB configuration file.Note: The
bind-address
directive may also be specified in the/etc/mysql/mariadb.conf.d/50-server.cnf
file. If it is, make sure it is pointing to 0.0.0.0 instead of the loopback address. -
Restart MySQL/MariaDB server:
-
For Linux:
# service mariadb restart || service mysql restart
-
For Windows:
Start Plesk Services Monitor > select MySQLXX or MariaDBXX (where XX is a version) > click Restart.
-
To verify connectivity, log in from the remote server using MySQL Workbench or via CLI by executing the following command:
# mysql -u"example_db_user" -p"password" -h"example.com"