How to repair a corrupt table in MySQL
Occasionally, under circumstances involving high load on the server, multiple INSERTs and UPDATEs, coupled with many SELECTs (see Section 28.5 for the syntax of SQL code), or hardware failure, your database server may corrupt a table. This is something it shouldn’t happen, but of course this doesn’t help you if it does. According to the MySQL manual on Corrupted MyISAM Tables, you can get corrupted tables if some of the following things happens:
- The mysqld process being killed in the middle of a write.
- Unexpected shutdown of the computer (for example, if the computer is turned off).
- A hardware error.
- You are using an external program (like myisamchk) on a live table.
- A software bug in the MySQL or MyISAM code.
and the typical symptoms for a corrupt table are:
- You get the error
Incorrect key file for table: '...'. Try to repair it
while selecting data from the table.
- Queries don’t find rows in the table or return incomplete data.
