Wednesday 8 July 2015

Enabling remote access for MySQL


When you install MySQL, only local access is enabled by default. Remote access is restricted in 2 ways:
In the config file /etc/mysql/my.cnf
Comment out the bind-address line:

#bind-address           = 127.0.0.1

User access

To enable the ruser from anywhere, you must use the grant command:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;

Replacing 'USERNAME' and password 'PASSWORD' with your own values of course.

After modifying the config file, you must restart the mysql service:

$ service mysql restart

Don't forget to use "sudo" (or su) if you're not logged in as root.