Symptoms
MySQL service fails to start with the following error message in /var/log/mysql/error.log
:
Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
Cause
The mysql system database is corrupter or is missing. It is often happens after hard reset of the server.
Resolution
-
Connect to the Plesk server via SSH.
-
Modify the
my.cnf
file:2.1. Open the
my.cnf
file in a text editor. In this example, we are using the vi editor:-
on CentOS/RHEL-based distributions
# vi /etc/my.cnf
-
on Debian/Ubuntu-based distributions
# vi /etc/mysql/my.cnf
2.2. Add the
skip-grant-tables
line under the[mysqld]
section:[mysqld]
skip-grant-tables
<...>2.3. Save the changes and close the file.
-
-
Restart the MySQL/MariaDB service:
# systemctl restart mysql
# systemctl restart mariadb
-
Switch to the directory with daily dumps:
# cd /var/lib/psa/dumps
-
Restore the database from the latest daily dump:
# zcat mysql.daily.dump.0.gz | sed -n '/-- Current Database: `mysql`/,/-- Current Database:*/p' | plesk db
-
Remove the
skip-grant-tables
directive which was added on step 2. -
Restart the MySQL/MariaDB service:
# systemctl restart mysql
# systemctl restart mariadb