Are you trying to find a solution for ‘ERROR: PleskDBException: Unable to connect to database’? We can help you fix it.
This error can occur due to various reasons that include InnoDB engine corruption, disk space full, data directory not completely restored or recovered, and so on.
Here at Bobcares, we often receive requests relating to database issues as part of our Server Management Services for web hosts and online service providers.
Today, let’s see how our Support Engineers fix this Plesk error.
How to fix error: pleskdbexception: unable to connect to database
Recently, one of our customers approached us telling us that when he tried to access the Plesk control panel, the following error appears:
“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)”
MySQL works fine and even the web applications are running without any problems.
Now let’s take a look at how our Support Engineers resolve this error.
We went through the MySQL logs by running the below command.
grep mysql /var/log/syslog | tail -50
As a result, we found the below log entries.
Mar 21 00:16:58 h2600744 /etc/init.d/mysql: 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: #007/usr/bin/mysqladmin: connect to server at ‘localhost’ failed Mar 21 00:16:58 h2600744 /etc/init.d/mysql: 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: Check that mysqld is running and that the socket: ‘/var/run/mysqld/mysqld.sock’ exists!
Here are the steps we follow to resolve this error.
First, we rename the file /etc/init/mysql.conf to /etc/init/mysql.conf.off. For that, we run the below command.
# mv /etc/init/mysql.conf /etc/init/mysql.conf.off
Next, we start the MySQL service. For that, we run the following commands.
# 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 we check if the data directory is completely restored/recovered. If not, we will need to recover it.
* Also, we delete files that are not needed so that we can free up some disk space. We can check the disk space using df and du commands.
# df -h
The du command displays disk usage. Or else, we can run the below command.
# 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.
[Still, not able to fix database problems? – We’d be happy to help you]
In short, this error can occur due to various reasons that include InnoDB engine corruption, disk space full, data directory not completely restored or recovered, and so on. Today, we saw how our Support Engineers fix this error.
var google_conversion_label = “owonCMyG5nEQ0aD71QM”;