Applicable to:
- Plesk for Linux
Symptoms
- Unable to log in to Plesk, the following error appears:
ERROR: PleskDBException: Unable to connect to database: mysql_connect(): Permission denied /var/lib/mysql/mysql.sock (Error code: 2002).
ERROR: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] Permission denied' in /usr/local/psa/admin/externals/Zend/Db/Adapter/Pdo/Abstract.php
-
Unable to start
service with the following error:
mariadbsystemd[1]: Starting MariaDB database server...
mariadb-prepare-db-dir[4030]: chmod: changing permissions of Б─≤/var/lib/mysqlБ─≥: Operation not permitted
mariadb-prepare-db-dir[4030]: Initializing MySQL database
mariadb-prepare-db-dir[4030]: chown: changing ownership of Б─≤/var/lib/mysqlБ─≥: Operation not permitted
mariadb-prepare-db-dir[4030]: Cannot change ownership of the database directories to the 'mysql'
mariadb-prepare-db-dir[4030]: user. Check that you have the necessary permissions and try again.
mariadb-prepare-db-dir[4030]: Initialization of MySQL database failed. -
Unable to access MySQL/MariaDB database. The following error appears if trying to log in to database using
utility:
mysqlERROR 1018 (HY000): Can't read dir of './db-name/' (errno: 13)
-
The permissions of
are different from listed below:
/var/lib/mysql/# ls -ld /var/lib/mysql
drwxr-xr-x 5 mysql mysql 4096 Apr 20 13:05 /var/lib/mysql
Cause
Incorrect permissions for
directory and its subdirectories.
/var/lib/mysql/
Resolution
- Log in to the server via SSH;
Note: if direct SSH access to the server is not possible, contact server administrator for further assistance.
-
Set proper owner to the directory and files:
# chown -R mysql:mysql /var/lib/mysql
# find /var/lib/mysql/* -type d -exec chmod 0700 {} ;
# find /var/lib/mysql/* -type f -exec chmod 0660 {} ;For Debian/Ubuntu
# chmod 700 /var/lib/mysql
For RHEL/CentOS
# chmod 755 /var/lib/mysql