Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

mysql

centos7

I have installed Centos7 update, removed MariaDB and done a fresh install of MySQL - additionally I have removed it and reinstalled it but everytime I connect to mysql -u root -p I get the titled error. Additionally I have looked at other tickets associated with this but still not making progress. If I run service mysqld restart it says "Redirecting to /bin/systemctl restart mysqld.service" and then just hangs. Really not a linux expert so not sure what is causing this?

like image 817
Ukuser32 Avatar asked Oct 02 '14 15:10

Ukuser32


1 Answers

I had the same problem and found out a few things after digging around. MariaDB is a drop-in replacement for mysql. On the new system, mysql is the MariaDB client (although I'm not clear on what that means). I checked to see if the service was running:

service mysqld status

which indicated:

Redirecting to /bin/systemctl status mysqld.service mysqld.service Loaded: not-found (Reason: No such file or directory) Active: inactive (dead)

In other words, the mysqld service is not running.

Starting the service worked for me:
`systemctl start mariadb.service`

Now all the mysql commands work as expected.

To tie the last knot, enable the service at boot:
`systemctl enable mariadb.service`
like image 110
John L Avatar answered Nov 14 '22 22:11

John L