MySQL Error Table ‘mysql.servers’ doesn’t exist

While trying to grant privileges to a MySQL user on a plain CentOS 6.x server, I was receiving this error at the mysql console: MySQL Error Table ‘mysql.servers’ doesn’t exist

I was surprised… the first thing that came to my mind was ‘mysql database got corrupted’, and indeed that was the problem. The mysql.user table should definitely exist on normal MySQL installations, so something was messed up on the MySQL installation.

Fixing MySQL Error Table ‘mysql.servers’ doesn’t exist error

Try to check if mysql.user exists

use mysql;
select * from user;

The firs thing I tried to fix this issue was to re-install mysql database to re-create all the mysql default tables starting MYSQL without any privileges:

/usr/bin/mysql --skip-grant-tables &
mysql -u root

Then tried running this as root from the Linux terminal:

mysql_install_db

After that, killed the previous MySQL process and restarted MYSQL normally:

ps -aux | grep mysql

And kill -9 all the process.

service mysqld restart

If that doesn’t solve your problem, check your MySQL data directory permissions, maybe they changed somehow.

Last option: create a full mysql dump of every database, remove mysql completely and re-install from scratch.

Create backups of every database:

MYSQLPASS=putyourmysqlrootpasshere
for i in $(mysql -u root -p$MYSQLPASS -Bse 'show databases'); do mysqldump --opt -p$MYSQLPASS $i -c> /root/mysql-dump-$i.sql; done

Check if your backups are ok:

ls -alh /root/mysql-dump*

Remove MySQL server

yum remove mysql-server
rm /var/lib/mysql -rf

Reinstall MYSQL Server

yum install mysql-server
service mysql start

Create all databases manually, same as privileges and mysql users, and then dump back your .sql backups into each database.

Conclusion

As you saw, the only solution I found for this was to remove mysql completely and reinstall from scratch. However… do you know any other fix for MySQL Error Table ‘mysql.servers’ doesn’t exist error?

 

Further reading:

About the Author: Santiago Borges

Experienced Sr. Linux SysAdmin and Web Technologist, passionate about building tools, automating processes, fixing server issues, troubleshooting, securing and optimizing high traffic websites.

Leave a Reply

Your email address will not be published. Required fields are marked *