Table of Contents

Enabling your MySQL server for remote access

All database/MySQL tutorials


You can configure your MySQL server to be accessed from a remote server. This can be useful if you would like to keep your database server separate from your web or other servers.

1. Grant rights to a username

To do this, you will need to grant rights to a MySQL user so that the user has rights to the database from somewhere other than the server where your database is hosted (localhost). Do this by using something like the following:

grant all privileges on *.* to remoteuser@123.123.123.123 identified by "userpassword";

Where:

When done, do not forget to flush the privileges with the command:

flush privileges;

2. Edit my.cnf

Edit the configuration file:

nano /etc/mysql/my.cnf

By default MySQL only listens to localhost. You will need to comment out the bind-address line in your MySQL configuration file:

bind-address           = 127.0.0.1

3. Restart your MySQL server

/etc/init.d/mysql restart