Today one of our computer’s /usr partition filled up and caused data corruption in the database. After space was freed up on the partition, we (Moises and I) ran some commands to repair the database. Here is what we did:
- cd into your directory where your db files are stored. In our case it was in the /usr…/data/mysql/ folder.
- We then run the command:
myisamchk *.MYI | grep -3 –color corrupted - This should give you some output on the current state of your files and indicate which files are corrupted and needing repair. It also gives you the next command to run on the line that reads:
Fix it using switch “-r” or “-o” - So that is just what we did
myisamchk -r file.MYI - Voila, your db should be repaired
One Comment, Comment or Ping
Nate Murray
Note that mysqlisamchk only works for MyISAM tables. For innodb data recovery check out:
http://code.google.com/p/innodb-tools/
Jul 11th, 2008
Reply to “Repairing your MySQL database”