How to repair crashed tables in MySQL

I’ve had MySQL database corruption from time to time, usually on a system that either experiences a power failure or kernel panic. The process is not difficult but I always find myself relearning how to do it each time. The program mysqlcheck comes in handy to check for errors and repair them.

The error that was reported recently when I did this was “Table ‘[SOME TABLE NAME]’ is marked as crashed and should be repaired”. The command I used to repair the problem (and that I believe I’ve used int he past) was:

  • mysqlcheck -A --auto-repair

This provides a pretty good status report as to what tables have issues, what the issues are, and what it does to fix them. For example it might read something like “warning : Number of rows changed from 5 to 4”.

Creative Commons License Except where otherwise noted, content on this site is licensed under a Creative Commons by-nc-sa 3.0 License