Repair and optimize all of the databases on your server with one command

October 22, 2015 — Leave a comment

When your server goes down hard, locked up or otherwise, you’ll sometimes find that you have some crashed tables. Why not fix them all in one swoop with one command from the cli?

Find crashed tables:

First, let’s see if you have any crashed tables. You want to look in the MySQL error log for your server, usually located in /var/lib/mysql/ and named something like hostname.err (ie:

Cat the file looking for crashed tables:

If you see things like:

Then you have crashed tables.

Fix those crashed tables:

So you have some crashed tables eh? Here’s a command that will go through and check them, repair them, then optimize them all.

This command will ask you for the root password…

If you don’t have a root password on your MySQL (shame on you), then use this one:

And there you have it.. easy right?

No Comments

Be the first to start the conversation.

Leave a Reply