Mysql couldn’t find the Mysql Server or Manager

In a beautiful day, all your websites couldn’t connect to database, although you didn’t make any changes. You get the error “Error connecting to MySQL: Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)” in your DirectAdmin or Cpanel. That’s mysql Couldn’t find the mysql server or manager. I’ve there, so i wrote this post to help you resolve this big problem with a simple way.

When connecting to a MySQL server located on the local system, the mysql client connects through a local file called a socket instead of connecting to the localhost loopback address For the mysql client, the default location of this socket file is /tmp/mysql.sock. However, for a variety of reasons, many MySQL installations place this socket file somewhere else like /var/lib/mysql/mysql.sock.

Solution 1: This is the best simple way for resolve all problems which you don’t know – REBOOT YOUR SERVER. I’ve got that error and reboot my vps and everything works fine.

shutdown -r now

Solution 2: Some my friends have tried restart MySQL and succeed but there are a few people get this error:

[root@server ~]# /sbin/service mysqld restart
MySQL manager or server PID file could not be found!       [FAILED]
Starting MySQLCouldn't find MySQL manager or server        [FAILED]

Step 1: Rem out the line in /etc/my.conf that was setting basedir to /var/lib. As seen below:


Step 2: Create the directory “/var/run/mysqld” if it does not exist. Then chown that directory to mysql.mysql as below:

mkdir /var/run/mysqld
chown mysql.mysql /var/run/mysqld

Step 3: Start the service:

service mysql start

Hope this post is useful with you !

Leave a Reply

Notify of