Can’t open and lock privilege tables: Table ‘mysql.host’ doesn’t exist
Fatal error: Can’t open and lock privilege tables: Table ‘mysql.host’ doesn’t exist
I faced this problem while i was shifting the location of mysql data directory to some non-default location. I copied all the files from /var/lib/mysql(default data location) to the /newdir and changed path in /etc/my.cnf also.
When i tried to run the mysql service, It gave following error in /var/log/mysqld.log
Fatal error: Can’t open and lock privilege tables: Table ‘mysql.host’ doesn’t exist
It seems like service was not able to locate some table in mysql db. Tries few searches and found a solution:
Install mysql db again at new location,use following command:
mysql_install_db --user=mysql --ldata=/new-data-location
mysqld_safe --datadir=/new-data-location --user=mysql &
I skipped last command and used /etc/init.d/mysqld start
Most Commented Posts
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.
Comments
Add me to the list of ones that you helped!! I lost my mysql database after a power outage and was able to restore it nicely
Thank you!!
Just to let you know, this obviously doesn’t work for Windows. I had a similar problem w/ a new Windows Vista x64 install. The fix (found elsewhere on the ‘net): get the .ZIP package, extract it to a temp directory, and selectively copy duplicate folders from the temp directory to your install directory.
This allowed me to start up my MySQL service immediately.
My only cure for this trouble so far has been to keep running pre 5.0 servers on win xp pro sp3. Is the 5.1.48 installer broken? Will mysql just not fix the installer out of spite? Why? I hope extracting files from the zip does the job!
WaLa! Problem on WindowsXP pro sp3 fixed!
I just used the old config wizard version 1.0.14.0. DO NOT use 1.0.16.0.
I deleted the database “mysql” with my tool SQLYog, and after i restarted the computer mysql wouldn’t start and gave this error.
I restored the folder “mysql” from a backup to my data-dir, and now it works.
It’s weird that you can delete a database which is essential for the startup of mysql.
PS: i wouldn’t try the rm -rf thing above. It’s like delete everything, no questions asked.
Thank you, I had quite a bit of trouble with this and this is the only post I found that said to rebuild using options to change the directory.

I faced the same problem. commands above mentioned solved it thanks.
Periyasamy