Unable to Connect to Any of the Specified MySQL Hosts.


If you get the following error while trying to connect to a MySQL database using a third party client such as TOAD or SQL Workbench, then you need to edit your mysql server’s my.cnf file.

Error Message: Unable to connect to any of the specified MySQL hosts.

So open the my.cnf file by running a similar command to the following one dependent on your server’s setup:

vi /etc/mysql/my.cnf

Then edit the bind-address from what is probably set as 127.0.0.1 (also known as localhost) to your server’s remotely accessible IP address.

If you are unsure what your server’s IP address is then you need to ping it from the command line on another machine outside it’s network (e.g. your own machine) as follows:

ping yourhost.com

N.B. If you are running a Dovecot/Postfix type email gateway setup on the same machine, changing your mysql bind-address will affect it’s connection to the database and you will no longer be able to send/receive emails through it. So you will have to adjust your Dovecot/Postfix configuration files where relevant.