How to solved server socket?

November 10, 2015 514 views

Link to database cannot be established: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

2 Answers
jtittle November 11, 2015
Accepted Answer

@Jabo - Have any changes been made to MySQL? If so, what changes were made? That specific error is a good sign that MySQL has crashed, failed to restart or has been stopped. In the case of the config, changes can cause MySQL to fail to start. Given that MySQL is rapidly developed and changes are always being made, it's entirely possible that your my.cnf file is attempting to interpret a configuration variable that is no longer used or does not apply to your setup.

If you made changes to my.cnf before shutting MySQL down, and then abruptly restarted it, this too can cause such an error.

Ultimately, you would need to login as root, run top and see if any instances of MySQL are running. If so, kill them off. You can also run ps -ef | grep mysql to see if any MySQL processes pop up to confirm all are killed off.

You should then be able to restart MySQL from the CLI.

Have another answer? Share your knowledge.