ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
I use the following command:
mysql -u root -h 127.0.0.1 -p
And the error message is:
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
How can I fix it?
Solution 1:
If you are using Ubuntu, you have to use the following steps to avoid this error (if there is no replication enabled):
- run the command
vim /etc/mysql/my.cnf
- comment
bind-address = 127.0.0.1
using the # symbol - restart your MySQL server once.
In Step 1, if you cannot find bind-address
in the my.cnf
file, look for it in /etc/mysql/mysql.conf.d/mysqld.cnf
file.
Update in case of MySQL replication enabled
Try to connect MySQL server on the IP address for which MySQL server is bound in file my.cnf instead of localhost or 127.0.0.1.
Solution 2:
Try localhost instead of 127.0.0.1 to connect or in your connection-config
. It worked for me on a Debian 6.0 (Squeeze) Server.