Question

How to solved server socket?

Posted November 10, 2015 1.9k views
CentOS MySQL

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

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

2 answers

@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.

Submit an Answer