Networking HowTos
Networking HowTos

Allowing remote connections to a MySQL server

January 1, 2013 Database, Linux, MySQL

A default installation of MySQL server on a Linux machine will only listen for connections on the local interface (localhost or, so any remote connections can not be established.
This how to article outlines the steps to change the configuration to listen on a specific, or all interfaces on the machine.

Open the MySQL configuration file (my.cnf) in a text editor:

$ sudo nano /etc/mysql/my.cnf

This configuration file is split into sections. The section we want is the “[mysqld]” section.
Find the setting “bind-address” under the “[mysqld]” section.
By default, it will look like this:

bind-address           =

This needs to be changed to either a specific IP address that you want MySQL to listen on, or to to listen on all interfaces/IP’s associated with the machine.

bind-address            =

Save the file and exit the editor.
Restart MySQL to activate these changes:

$ sudo service mysql restart

You should now be able to connect to the MySQL server from another PC.
Make sure you set up the required permissions for the users and databases if they need to be able to connect to the MySQL server remotely. Generally users will only be allowed to login from localhost unless they have been configured otherwise.

You Might Also Like