Enable Remote Access for MySQL Database

By default remote access to MySQL database server is disabled for security reasons. However, some time you need to provide remote access to database server from home or a web server.

This can be done very easily, I did it on a CentOS, here is the how-to:

Log into the database server, enter the MySQL shell and select the database you want.

shell> mysql -u root -p

mysql> use database_name;

Then use this SQL command:

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’;


Well, most of the time you wouldn’t do this as that SQL command will grant ALL privileges to user ‘root’ for ANY IP/host!

Something sensible:

mysql> GRANT SELECT ON *.* TO ‘dummy’@’’;

That will limit the access for user ‘dummy’ from ‘’ to SELECT only.

More examples and references can be found on MySQL’s website.

On some servers you need to do more work before enable remote access by this method (bind MySQLd, open port 3306, etc.) If the above instruction doesn’t work for you, have a look at this excellent tutorial: http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html

Leave a Reply

Your email address will not be published. Required fields are marked *