ERROR 2002: Cant connect to local MySQL server through socket /tmp/mysql.sock solution

  

Install LAMP today, start the service when installing MySQL always fails, prompt ERROR 2002: Can't connect to local MySQL server Through socket '/tmp/mysql.sock' (2)

Check it out, there is indeed /tmp/mysql.sock this file. If you create it?

Go to the network to find more information, restore mysql.sock, the result is still not, finally read the installation file and then know that the file in /etc/my.cnf is wrong, you need to re-create one, so I copied a copy again, the steps are as follows:

cd mysql-VERSION to the directory where the files are extracted

Copy

cp support-files/my-medium.cnf /etc/my.cnf

Reinitialize, create an authorization table

bin/mysql_install_db --user=mysql


Start the service

bin/mysqld_safe --user=mysql &

It’s OK to reconnect again. The solution to this problem on the network is N, it’s too embarrassing, I’ve seen it for a long time, it’s just Wasting time, now I am finally done!

Copyright © Windows knowledge All Rights Reserved