Symptoms
Plesk login page shows the following error:
ERROR: Zend_Db_Adapter_Exception: SQLSTATE[HY000] [2002] Connection refusedIn
/var/log/mysqld.logthe following error can be found:[ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory)
The following error may be found in
/var/log/mariadb/mariadb.logfile:[ERROR] mysqld: Can't create/write to file '/var/run/mariadb/mariadb.pid' (Errcode: 2)
[ERROR] Can't start server: can't create PID file: No such file or directory
mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid endedCONFIG_TEXT:2020-08-05 1:04:22 0 [ERROR] mysqld: Can't create/write to file '/var/run/mariadb/mariadb.pid' (Errcode: 13 "Permission denied")
2020-08-05 1:04:22 0 [ERROR] Can't start server: can't create PID file: Permission deniedDirectory
/var/run/mysqld(for Debian and Ubuntu) or/var/run/mariadb/(for CentOS) is absent or has incorrect permissions:Debian and Ubuntu:
# ls -lad /var/run/mysqld
ls: cannot access /var/run/mysqld: No such file or directoryCentOS:
# ls -lad /var/run/mariadb/
ls: cannot access '/var/run/mariadb/': No such file or directory
Cause
MySQL directory is absent so the system cannot create PID file for the service on startup.
Resolution
Note: This article may require additional administrative knowledge to apply. If any help required, contact server’s administrator or hosting support.
Connect to the server via SSH.
Create the configuration file with necessary content:
For Debian/Ubuntu:
# echo "d /var/run/mysqld 0755 mysql mysql -" >> /etc/tmpfiles.d/mysql.conf
For CentOS/RHEL/CloudLinux:
# echo "d /var/run/mariadb 0755 mysql mysql -" >> /etc/tmpfiles.d/mysql.conf
Reboot the server.
Click on a section to expand
Solution without reboot for CentOS/RHEL/CloudLinux
Connect to the server via SSH.
Run the commands below:
# install -dpm770 -o mysql -g mysql /var/run/mariadb
# systemctl start mariadb