UnixServerAdmin

Server Administration & Management

How to enable remote access to a MySQL Server

MySQL is often configured to be accessible from the local host only. The MySQL configuration file is at /etc/mysql/my.cnf on Debian and similar distros and /etc/my.cnf on CentOS, Red Hat Enterprise Linux and Fedora. It contains a bind-address setting which is often set as follows by default:

bind-address = 127.0.0.1

This binds the MySQL deamon to 127.0.0.1 which is the local machine and means it will not be able to be accessed from other machines, whether or not the firewall and/or privilege grant options allow it.

To allow it to be accessible from any host, comment the line out as shown in the following example and then restart MySQL:

#bind-address = 127.0.0.1

Note that you could set the IP address to that of the server but it will mean all connections to the MySQL server must be via that IP address as it is not currently possible to bind MySQL to more than one IP address. It’s simply easier to comment the line out.

# /etc/init.d/mysql restart

You’ll still need to enable access to the MySQL server through the firewall from the remote server(s) and add/modify the appropriate permissions to the privileges tables.

Advertisements

February 16, 2011 Posted by | MySQL | , | 1 Comment