‘PleskDBException: Unable to connect to database Error’

The error is caused by the various reason that includes disk space full, InnoDB engine corruption, and data directory not completely restored.

Our technical team support will fix the Plesk error under our Plesk server management services plan. You can also take assistance from our technical team support 24/7 for fixing the error or any sort of installation and migration. 

How to fix error

This was one of the client reports that tell us that he tries to access the Plesk control panel and the following error appears on the screen.

“ERROR: PleskDBException: Unable to connect to database: mysql_connect(): No such file or directory /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that the database server is started and accessible. (Abstract.php:69)”

Whereas MySQL is working well and even the web application has worked well without any sort of issues.

Resolve this error.

We went through the MySQL logs by running the below command.

grep mysql /var/log/syslog | tail -50

The following are the result.

Mar 21 00:16:58 h2600744 /etc/init.d/mysql[29323]: 0 processes alive and ‘/usr/bin/mysqladmin –defaults-file=/etc/mysql/debian.cnf ping’ resulted in Mar 21 00:16:58 h2600744 /etc/init.d/mysql[29323]: #007/usr/bin/mysqladmin: connect to server at ‘localhost’ failed

Mar 21 00:16:58 h2600744 /etc/init.d/mysql[29323]: error: ‘Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)’ Aug 12 00:16:58 h2600744 /etc/init.d/mysql[29323]: Check that mysqld is running and that the socket: ‘/var/run/mysqld/mysqld.sock’ exists!

Follow the few steps to resolve this error

First, we rename the file /etc/init/mysql.conf to /etc/init/mysql.conf.off. For that, you need to run the below command.

# mv /etc/init/mysql.conf /etc/init/mysql.conf.off

Later, run the command to restart the MySQL service.

# sudo service mysql stop
# sudo service mysql start​

Also, we can also perform “plesk repair db -v”.

The socket will not exist if mysqld refuses to start. So you need to check whether the data directory is restored properly. If not, you need to recover it.

You need to delete the non-essential file, in order to gain some disk space by using the df and du commands.

# df -h

The du command displays disk usage. 

# du -h

Moreover, we can add the skip-grant-tables option into /etc/mysql/my.cnf after that we should be able to start the database server.

Conclusion

In brief, the error is caused by the various reason that includes disk space full, InnoDB engine corruption, data directory not completely restored. Follow the steps to fix the problem, if you still face the issue you take our technical team support to fix this error.

More Posts

Send Us A Message

Prevent your Website/Server from Downtimes

Get our experts to manage your server with weekly auditing and 24/7 monitoring