Check and repair mysql database tables with myisamchk (and mysqlcheck)

Useful after systemcrash:

When Mysql is not running:

 myisamchk –silent –force –fast –update-state /var/lib/mysql/bugs/*.MYI

myisamchk –safe-recover –force –sort_buffer_size=2G –key_buffer_size=2G /var/lib/mysql/*/*.MYI

-s, –silent option: Prints only errors. You can use two -s to make myisamchk very silent.
-f, –force option: Restart myisamchk automatically with repair option -r, if there are any errors in the table.
-F, –fast option: Check only tables that haven’t been closed properly.
-U –update-state option: Marks tables as crashed, when it finds any error.

When Mysql is running (which is kind of slow)

mysqlcheck –repair –all-databases




Leave a Reply

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