Unable to log in to Plesk: ERROR: PleskDBException: Unable to connect to database

Created:

2016-11-16 12:38:47 UTC

Modified:

2017-08-16 15:45:51 UTC

8

Was this article helpful?


Have more questions?

Submit a request

Unable to log in to Plesk: ERROR: PleskDBException: Unable to connect to database

Applicable to:

  • Plesk for Linux

Symptoms

Unable to log in to Plesk because of issues with connection to database, errors like below may appear:

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

General troubleshooting steps

First of all, check whether MySQL service is running or not:

On CentOS/RHEL :

# service mysqld status

On Ubuntu/Debian :

# service mysql status

If you use MariaDB server:

# service mariadb status

If it is not running, try to start it with start command, e.g.:

# service mysqld start

If it does not start, check MySQL log files. You can find the location of log files in MySQL configuration. MySQL configuration files can be found by the following command:

# mysql --help | grep -A1 "Default options"
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf

The location of MySQL log files is defined by " log-error " setting in " my.cnf " file, for example:

# grep -B1 log-error /etc/my.cnf
[mysqld_safe]
log-error=/var/log/mysqld.log

If " log-error " is not defined, you can define it on your own having backed the original file. Please, note that " log-error " option should be defined in " [mysqld_safe] " section.

Check if there no hanged mysqld processes using:

# ps auxffww | grep mysql

Manually kill hanged processes:

# kill -9 PID_ID

Related issues

  • 128949 Unable to log in to Plesk: Unable to connect to database: mysql_connect(): No such file or directory /var/lib/mysql/mysql.sock (Error code: 2002)

    • Unable to log in to Plesk, the following error appears in Plesk interface:

      ERROR: PleskDBException: Unable to connect to database: mysql_connect(): No such file or directory /var/lib/mysql/mysql.sock (Error code: 2002). Please check that database server is started and accessible. (Abstract.php:69)
    • When trying to run plesk repair db -v in CLI the output is as follows:

      Broken table exp_event: 107 clients are using or haven't closed the
      table properly .................................................... [WARNING]
    • When trying to backup psa database:

      # mysqldump -uadmin -p --skip-extended-insert  psa > psa.dump.`date +%F.%s`.sql
      mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table `table_name` at row: xxxx
    • When trying to check a faulty table from previous step:

      # mysqlcheck -c psa table_name -uadmin -p
      mysqlcheck: Got error: 2013: Lost connection to MySQL server during query when executing 'CHECK TABLE ... '
  • 121018 Unable to access Plesk: psaerror(string 'Unable to connect to database: mysql_connect().

    • Unable to log in to Plesk, the following error is shown:

      ERROR: PleskFatalException
      Unable to connect to database: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: No such file or directory
      0: common_func.php3:153
      psaerror(string 'Unable to connect to database: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: No such file or directory')
      1: auth.php3:112
    • Unable to login to MySql, the following error is show:

      ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
    • The following warning can be observed in the /var/log/mysql/error.log :

      140410 17:32:26InnoDB: Warning: difficult to find free blocks from
      InnoDB: the buffer pool (986 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: 139 OS file reads, 0 OS file writes, 0 OS fsyncs
      InnoDB: Starting InnoDB Monitor to print further
      InnoDB: diagnostics to the standard output.
  • 119920 PleskFatalException: Unable to connect to database: get_admin_password() failed.

    • When opening Plesk interface in browser, it shows the following error:
      ERROR: PleskFatalException: Unable to connect to database: get_admin_password() failed: file_get_contents() failed: file_get_contents() failed: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Tokyo' for 'JST/9.0/no DST' instead (auth.php:142)
  • 124838 Unable to connect to database: mysql_connect() function.mysql-connect: Permission denied.

    • Unable to access Plesk, page shows error:

      Error message or request description : ERROR: PleskFatalException
      Unable to connect to database: mysql_connect() function.mysql-connect: Permission denied
    • MySQL service failed trying to restart.

    • In /var/log/mysqld.log these errors can be found:

      [ERROR] /usr/libexec/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 13)
      [ERROR] Can't start server: can't create PID file: Permission denied
  • 213915205 Unable to access website hosted on CloudLinux 7: mysql_connect(): [2002] No such file or directory

    • Website showing the following error:

      Internal server error 500
    • In domain's error_log file it is possible to find the following error:

      PHP Warning:  mysql_connect(): [2002] No such file or directory (trying to connect via unix:///var/lib/mysql/mysql.sock)
    • CloudLinux 7 is installed and CageFS is also configured.

    • This command gives empty output:

      # grep "/var/lib/mysql" /etc/cagefs/cagefs.mp
Have more questions? Submit a request
Please sign in to leave a comment.