ERROR 2003 (HY000): Can’t connect to MySQL server on (111) – Solution

Symptom:

The error message:

ERROR 2003 (HY000): Can't connect to MySQL server on 'IP address' (111)

Appears white an attempt to connect to MySQL server remotely.

Solution:

By default the MySQL server is configure to disallow any remote access. The only accepted connection are allowed from the localhost thus 127.0.0.1 IP address. This configuration can be found in main MySQL configuration file /etc/mysql/my.cnf:

bind-address           = 127.0.0.1

To make MySQL server allow connection from any remote IP address amend the above line to 0.0.0.0 or comment the entire line:

bind-address           = 0.0.0.0
OR
#bind-address           = 127.0.0.1

And restart your MySQL server:

# service mysql restart
[ ok ] Stopping MySQL database server: mysqld.
[ ok ] Starting MySQL database server: mysqld ..
[info] Checking for tables which need an upgrade, are corrupt or were 
not closed cleanly..