Thursday, March 8, 2012

Table mysql.servers doesn’t exist: Problem adding a database user in plesk Or restarting mysql

SkyHi @ Thursday, March 08, 2012
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 is upgraded which introduce newer version of tables and the default Mysql database is not aware of these changes. The “mysql_fix_privilege_tables” command is use to update the Mysql database with the latest contents of the newer version and to fix the privileges of the database users as well.
Section 1:
To fix the issue, SSH to your server and execute:
On a plain Linux OR Linux/cPanel server:
# mysql_fix_privilege_tables --user=root\
 --password=mysqlpasswordhere --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:
mysql_upgrade command have superseded mysql_fix_privilege_tables. mysql_fix_privilege_tables is an older script that previously was used to upgrade the system tables in the Mysql database .
To fix the issue, you need to replace mysql_fix_privilege_tables with mysql_upgradein the above stated commands, i.e.
On a plain Linux OR Linux/cPanel server:
# mysql_upgrade --user=root --password=mysqlpasswordhere --verbose
On a Linux/Plesk server:
# mysql_upgrade --user=admin\
  --password=`cat /etc/psa/.psa.shadow` --verbose




REFERENCES
http://linuxhostingsupport.net/blog/problem-adding-a-database-user-in-plesk-or-restarting-mysql-table-mysql-servers-doesnt-exist
http://myeasylinux.wordpress.com/2010/07/20/table-mysql-servers/
http://stackoverflow.com/questions/3653021/error-table-mysql-servers-doesnt-exist