How to solved server socket?

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


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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

This comment has been deleted