Update: If “mysql_fix_privilege_tables” command does not exist, look at Section 2.
You may receive a “Table ‘mysql.servers’ doesn’t exist” error message while adding a database user in Plesk OR while restarting the Mysql service. The complete error message look like:
Error: Connection to the database server has failed: Table 'mysql.servers' doesn't exist
OR
Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
The problem mostly occurs when Mysql server is upgraded from an older to a newer version and the upgrade remains incomplete. Since Mysql often introduces new tables with the newer versions, you need to run the “mysql_fix_privilege_tables” script located in the “/usr/bin/” directory so the mysql database is updated with the latest contents thus fixing the privileges of the database users as well.
Section 1:
To fix the issue, SSH to your server as root and execute the command:
On a plain Linux OR Linux/cPanel server:
# mysql_fix_privilege_tables --user=root --password=<mysql password here> --verbose
On a Linux/Plesk server:
# mysql_fix_privilege_tables --user=admin --password=`cat /etc/psa/.psa.shadow` --verbose
where, –verbose will display the detailed output.
Section 2:
If mysql_fix_privilege_tables command does not exist, use mysql_upgrade instead. mysql_fix_privilege_tables is an older script that previously was used to uprade the system tables in the mysql database after a MySQL upgrade. mysql_upgrade command have superseded mysql_fix_privilege_tables.
To fix the issue, you need to replace mysql_fix_privilege_tables with mysql_upgrade in the above stated commands, i.e.
On a plain Linux OR Linux/cPanel server:
# mysql_upgrade --user=root --password=<mysql password here> --verbose
On a Linux/Plesk server:
# mysql_upgrade --user=admin --password=`cat /etc/psa/.psa.shadow` --verbose