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

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

Periyasamy

Got the same problem with WAMP. How do I do this with WAMP?

thanks… thats, what i need.

Thanks Daniel for your comment. I am happy that published solution solved your problem, cheers!

thanks , worked for me too .

Thanks….
it worked for me 2…..

Thanks Maneesh for your comment. I feel good whenever i see that post got used.

Good, I am happy that post is getting useful for you people.

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!!

:-) . Thanks for your comment.

Great help Aditya. Short and useful help

Thanks Sid, I am happy that you guys are finding it helpful.

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.

I am facing the same problem in windows7 can you help me out?

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.

Thank you very much for your post…!!!

Worked for me.

Glad to know that it is actually solving and saving time. Thanks for your comment.

Try rm -rf /var/lib/mysql/* and then see if it
will start.

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. :)

Thanks a lot. it worked for me..

Very helpful post.

saved my time … thanks :)

MUCHos THANKius por HELP ME :D

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.

Thanks!!

Leave a comment

(required)

(required)