MySql errors: "...Unit mysql.service not found." & "...Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)"

Whenever I give a command to MySQL, such as telling it to “start” or “restart”, I get this error:

Failed to start mysql.service: Unit mysql.service not found.

At other times (such as when I give the command “mysql”, I get this error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I just can’t get past either of these errors. I tried all kinds of solutions online and so far none of them work.

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.

Hi @IsaiahtheDolphin,

What does your Error_log say? In there you should see the exact error behind the issue.

The error log can be located in either your /var/log/ folder or in your MySQL folder /var/lib/mysql. If you are not certain you can always check the configuration file of MySQL - /etc/my.cnf. In there you can see where the log is located or if there isn’t any specified, you can create it.