123 Reg Support

Plesk unable to connect to the MySQL database

This article will explain what to do in the event that Plesk Panel is unable to connect to the MySQL database.

Please note: this article was originally created for our previous generation of Virtual Private Servers. As such, these instructions may not be relevant to our current generation of Virtual Private Servers.

If you get the following error message:

ERROR: PleskFatalException Unable to connect to database: mysql_connect() [function.mysql-connect]: Can’t connect to local
MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

0: common_func.php3:93 psaerror(string ‘Unable to connect to database: mysql_connect() [function.mysql-connect]: Can’t connect
to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)’) 1: auth.php3:127

The MySQL service did not load when the server was started.

 

Try stop/starting/restarting the MySQL service. If that does not work and you get the following error:

ERROR: PleskFatalException Unable to connect to database: mysql_connect() [function.mysql-connect]: Can’t connect to local
MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

0: common_func.php3:150 psaerror(string ‘Unable to connect to database: mysql_connect() [function.mysql-connect]: Can’t connect
to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)’) 1: auth.php3:107 ERROR: PleskFatalException Unable to connect to database: mysql_connect()
[function.mysql-connect]: Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

0: common_func.php3:150 psaerror(string ‘Unable to connect to database: mysql_connect() [function.mysql-connect]: Can’t connect
to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)’) 1: auth.php3:107

 

Check the error log /var/log/mysql/error.log to see if you can see:
120724 10:30:15InnoDB: Warning: difficult to find free blocks from
InnoDB: the buffer pool (2299 search iterations)! Consider
InnoDB: increasing the buffer pool size.
InnoDB: It is also possible that in your Unix version
InnoDB: fsync is very slow, or completely frozen inside
InnoDB: the OS kernel. Then upgrading to a newer version
InnoDB: of your operating system may help. Look at the
InnoDB: number of fsyncs in diagnostic info below.
InnoDB: Pending flushes (fsync) log: 0; buffer pool: 0
InnoDB: 130 OS file reads, 0 OS file writes, 0 OS fsyncs
InnoDB: Starting InnoDB Monitor to print further
InnoDB: diagnostics to the standard output.

 

This generally means that a large amount of data is being written to MySQL. Try to confirm which databases use large BLOB or Text fields and if you are importing lots of records.

Increase the innodb_buffer_pool_size entry in my.cnf from 2M to 20M. The ibdata file can be large in size (5-20GB+) however any larger can cause issues. Altering the query_cache_size file may help too. Then Restart MySQL.