ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")


ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2 “No such file or directory”)

After following all the steps of a tutorial to make a cluster with galley and mariadb. Everything worked fine until I made a copy and then create a new drop.

No matter what I do I always encounter this error when restarting mysql.

If I never turn off the drop or never recover with a previous image does not give the bug.

But I turn off the drop to make it bigger. Or I just turn it off and on.

It gives me this error and I did not step from this step.

Did anyone else tube this error?

Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

While this is an old question I though it might be good to answer for someone else who is having the same issue. For me it was a matter of /var/lib/mysql/tc.log growing rapidly in size. After removing the tc.log mariadb started working again.

I had the same problem. I just need to run sudo service mysql start it happen to me and worked on it for 15 mins and then I wanted to kick myself in the butt once I figure I need to start mysql. Sometimes it doesn’t always start. :)


One of the most common issues I’ve ran in to is the systemd or init script is passing a different path than is defined in your my.cnf file for the socket, thus when you attempt to start or restart MySQL, it fails.

So the best thing to do would be to check my.cnf and the associated configuration files to see what is being defined for the socket. If your MySQL configuration is defining something other than what the startup script is asking for, change socket= to /var/run/mysqld/mysqld.sock, save + exit, and then try to restart MySQL/MariaDB again.

Otherwise, you could do the reverse. Check the startup script and change the path of the socket to match that of what’s defined in your MySQL configuration.