Failed to connect to MySQL:: Can't connect to local MySQL server through socket

Created:

2016-11-16 12:48:59 UTC

Modified:

2017-04-18 22:40:38 UTC

0

Was this article helpful?


Have more questions?

Submit a request

Failed to connect to MySQL:: Can't connect to local MySQL server through socket

Symptoms

Upon the psa service restart the following error appears:

#/etc/init.d/psa restart
Stopping sw-engine-fpm: [ OK ]
Starting sw-engine-fpm: [ OK ]
Trying to connect to MySQL... Failed to connect to MySQL: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Cause

The issue might be caused by hung tasks.

Resolution

  1. Check if hung tasks, run ps -auf and check mysql related tasks:

    #ps -auf
    root 15588 0.0 0.0 106192 1524 pts/3 S 10:54 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.log
    mysql 15927 116 13.6 11373312 2237072 pts/3 Sl 10:54 173:59 \\_ /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=
  2. Kill hung task (run kill <PID> ) and restart psa service /etc/init.d/psa restart .

  3. Additionally please check the max_connections number in MySQL configuration, correct it if needed (MySQL configuration file is /etc/my.cnf ).

Have more questions? Submit a request
Please sign in to leave a comment.