1 min read

MySQL ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’

Somehow the MySQL server process did not create the socket, or the client is looking for the socket in the wrong place that is why MySQL is generate ERROR 2002 (HY000): Can’t connect to local MySQL server through socket

To prevent “MySQL Error 2002 Can’t connect to local MySQL server through socket“, we have to follow those steps.

I tried the following steps:

  • Log in as super user or use sudo
  • Open /etc/mysql/my.cnf using gedit
  • Find bind-address and change its value to the the database server host machine ip. For me, it was localhost or 127.0.0.1
  • Save and close the file.
  • Come back to terminal and execute sudo service MySQL start

General case it’s problem of my.cnf.

If you didn’t find solution you can try this option as well

 sudo apt-get install mysql-server  

execute above comment in terminal, after you found MySQL-server installation is process.

completation of whole installation process restart your server.

 sudo service mysql start  

You found the solution of your problem

Share your Love

Leave a Reply

Your email address will not be published. Required fields are marked *