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:
*.
is the database or databases that are authorized (* means all, but you can of course just choose one),remoteuser
is the MySQL username that you are granting remote access,123.123.123.123
is the IP Address of the remote server that you are granting access to (this can be replaced by * for ALL servers),userpassword
is the password of the MySQL user in question
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
Last modified: 07/17/2012 at 09:05 by Amy B. (Gandi)