How to repair all tables in all databases in MySQL

When your server loses power unexpectedly, or the kernel panics or otherwise terminates unexpectedly, your mysql tables are probably going to be damaged.

You might not find out about it for a while. It is a good idea to check and repair all your databases before the problems get worse.

mysqlcheck -u root -p --auto-repair --check --optimize --all-databases

That command will fix your databases. I was seeing a lot of locks and queries failing that should not have failed, and this command fixed it for me.

This entry was posted in Linux, mysql. Bookmark the permalink.

Comments are closed.