Are you getting an error message as “Unable to connect database” – PleskDBException?

Are you getting an error message as “Unable to connect database” – PleskDBException?

There is more number of reasons behind this notification such as directories of data that haven’t been restored or recovered properly, space filled up completely in the disk, and corruption in the InnoDB engine.

Let’s see how to connect the database without getting an error:

When you try to access the control panel of Plesk you might get an error like the below mentioned:

“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)”

Moreover, an application of web and MySQL works correctly. Use the below-mentioned code for running the logs of MySQL:

grep mysql /var/log/syslog | tail -50
You will get entries of logs such as

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!
Till now, we saw how the errors are displayed and how can you identify errors. Let us take a quick look to find the solution:

Take the first step to change the name of file as /etc/init/mysql.conf to /etc/init/

# mv /etc/init/mysql.conf /etc/init/ – This command will help you to rename the file.
Check the service of MySQL by executing the command

# sudo service mysql stop
# sudo service mysql start
Start performing Plesk repair db –v – If mysqld doesn’t start then you can’t see sockets there. Now, check the directories of data are recovered or restored. If the still problem exists then you need to recover it again.

Don’t forget to free up the space of the disk so, delete it frequently if not needed anymore. Use commands like du and df for checking the space of disks:

# df -h
# du -h
You can use either of the commands for checking the disk space.

Another option is to try by starting the server of the database by adding the skip-grant-tables directly into /etc/mysql/my.cnf.

That’s it! We have displayed the options for avoiding errors to connect the database. This might be easy for you to take the required steps.
First release
Last update
0.00 star(s) 0 ratings

More resources from kumkumsharma