Allow External Access to MySQL Server
The text on this page was translated by translation software. A revised version from our editors will be available soon.
For Linux Server
In this article you will learn how to make the MySQL server externally accessible.
When your server is delivered, no external access to the MySQL server is possible. In some cases, however, it is essential to access the MySQL server over the network. This includes the use of certain database management software, or the use of the server as a dedicated database server.
Customizing the MySQL Configuration
To allow network access to a MySQL database, modify the configuration of the MySQL server and restart it. You change the configuration in the /etc/my.cnf file.
Log in as root on your Dedicated Server and open the file /etc/my.cnf, for example with the editor vi:
root@p12345678:~ # vi /etc/my.cnf
Look for the bind-address = 127.0.0.1 line,
which tells the MySQL database to accept incoming network connections only from the loopback interface, disable it with a comment character ('#'):
#bind-address = 127.0.0.1
Please note: In some Linux distributions the above line is not available. Here, the line that is commented out is as follows:
Restart the database server so that your configuration change takes effect:
root@p12345678:~ # /etc/init.d/mysql restart
The MySQL server now accepts external connections through the default port for MySQL (3306).
Enter the following command:
Use the following commands to restrict access to your database to a specific IP address, replacing the example names and IP address with the desired data. Also make sure to press the ENTER button after each ;:
mysql> update db set Host='220.127.116.11' where Db='yourdatabasename'; mysql> update user set Host='18.104.22.168' where user='yourdatabaseUsername';
Exit the MySQl shell with the command Exit,