Saturday 1 December 2012

How to repair and recover corrupted MYISAM databases

The following command will help us to understand whether to repair the databases or not.
====
myisamchk --check /var/lib/mysql/*/*.MYI
====

First we can try to safe-recover the databases:
====
myisamchk --safe-recover /var/lib/mysql/*/*.MYI

or

myisamchk --recover /var/lib/mysql/*/*.MYI
=====

You can try forceful recover using the following command:
====
myisamchk --safe-recover --extend-check -force /var/lib/mysql/*/*.MYI

myisamchk --recover --extend-check -force /var/lib/mysql/*/*.MYI
====

Following commands will help to repair MYISAM databases.

The below command will repair all databases in the server. Please remember you have to keep mysql service stopped in the server while performing myisam repair.

====
/etc/init.d/mysql stop

myisamchk -r /var/lib/mysql/*/*.MYI
====


No comments:

Post a Comment

Note: only a member of this blog may post a comment.