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

Posted August 9, 2021 544 views
MySQLDebianUbuntu 20.04

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.

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.

Submit an Answer
1 answer

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.