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.
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.
-
-
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:
# service mysql restart
# service mariadb restart
If there are no daily dumps:
-
Connect to the server via SSH.
-
For security reasons, dump all databases.
-
Reinstall the MySQL system database with the command:
# mysql_install_db -
Configure it:
# /usr/bin/mysql_secure_installation
-
Secure the installation:
# /usr/bin/mysql_secure_installation
-
Recreate the admin user using the steps from this KB article.
-
Restore MySQL system users:
# plesk repair mysql
-
Restore the apsc user of:
# plesk repair db
-
Reinstall Roundcube webmail.