Article translated by machine

This text is a machine translation. A revised version is planned.

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.

Step 1

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 
Step 2

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:

Skip Networking 
step 3

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).

Restrict database access to specific IP addresses

Step 1

Log in to your MySQL shell on your server with the following command, have your root user or admin password ready:

root@serverName:~$ mysql -u admin -p
Step 2

Enter the following command:

use mysql; 
step 3

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='123.123.123.123' where Db='yourdatabasename';
mysql> update user set Host='123.123.123.123' where user='yourdatabaseUsername'; 
Step 4

Exit the MySQl shell with the command Exit,