If you install a MySQL or MariaDB server on your virtual server, it will be installed automatically with the „Allow local only“ rule. If you want to make the server accessible from outside, you have to change the configuration of the server.
We will show you with an example (MariaDB) how to do this.
Error message which means that MySQL is not reachable from outside:
ERROR 2002 (HY000): Can't connect to MySQL server on '168.119.29.XXX' (115)
- You need a Linux server.
- You must have MariaDB installed (apt-get install mariadb-server).
- The port 3306 must be released in a firewall, if one is used.
- You have created a user that can either access from anywhere „%“ or is filtered by IP address/host.
Modify the file /etc/mysql/mariadb.conf.d/50-server.cfg. Open it with an editor of your choice.
In the area under [mysqld] you will find the setting „bind-address“. Change the configuration as described below.
# Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. bind-address = 127.0.0.1
# Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. bind-address = 0.0.0.0
Save the file and restart your database server.
systemctl restart mysql
After that, your MySQL server is also accessible from the outside. For security reasons, we strongly recommend that you create a separate MySQL account for external users. The root access should only work internally.
If you have any questions about this topic, please contact us. We will be happy to help you!