Enabling MySQL Remote Access - MySQL connection only works from local machine

If the MySQL connection is only working locally, make sure the user has been granted privileges to be able to connection remotely to MySQL. The following is an example SQL statement to grant the user remote access:

GRANT ALL PRIVILEGES ON [database_name].* to '[user]'@'[hostname]' identified by '[password]'

Replace the database_name, user, hostname, and password values with their appropriate replacements.

If the connection to MySQL still does not work, make sure that networking is enabled on the MySQL database. For newer versions of MySQL, this can be achieved using the MySQL Server Instance Configuration Tool. One of the options on the tool is to enable TCP/IP networking. The tool will also allow you to specify a port (the default is 3306) and create a firewall exception.

On older versions of MySQL, you may have to edit the MySQL configuration manually. On Windows machines, this would typically be the my.ini file located in your MySQL installation directory. On Linux / Unix, the global configuration file would be the my.cnf file located in the /etc directory. The my.cnf file in the MySQL data directory can be used for specific server configuration, and the my.cnf file in the user home directory can be used for user specific configuration.

To enable networking manually, make sure the skip-networking line is commented out, and the following line is contained in the file with the SERVER-IP replaced with the actual ip address of the server:


Also, make sure the port MySQL is listening on is open to ip addresses from which you will be connecting to the server, or to all ip addresses if that is acceptable to your security policy.