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

Charlie Epps picture Charlie Epps · Nov 4, 2009 · Viewed 467.9k times · Source

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)

Who can help me to fix it?

Answer

Justin Vincent picture Justin Vincent · Apr 23, 2013

If you are using ubuntu, you have to use the following steps to avoid this error(if there is no replication enabled):

  1. run the command vim /etc/mysql/my.cnf
  2. comment bind-address = 127.0.0.1 using the # symbol
  3. restart your mysql server once.

Update

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 IP for which MySQL server is bind in 'my.cnfinstead oflocalhost or 127.0.0.1`.