Even if the MyISAM table format is very reliable (all changes made to the table by a SQL statement are written before the statement returns), you can still get a corrupted table if any of the following events occur:
· The mysqld process is killed in the middle of a write.
· An unexpected computer shutdown occurs (for example, the computer is shut down).
· Hardware failure.
· You can use external programs (such as myisamchk) on tables being modified by the server at the same time.
· Software defects in MySQL or MyISAM code.
Typical symptoms of a corrupted table are:
· When selecting data from the table, you get the following error:
· Incorrect key file for table: '...'. Try to repair it
· The query cannot find the row in the table Or return incomplete data.
You can use the CHECK TABLE statement to check the health of a MyISAM table, and use REPAIR TABLE to repair a damaged MyISAM table. When mysqld is not running, you can also use the myisamchk command to check or repair a table.
If your table becomes corrupted frequently, you should try to determine the reason why this is happening. The most important thing to understand is whether the table became corrupted as a result of the server crashing. You can verify this early by looking in the error log for the most recently restarted mysqld message. If such a message exists, it is very likely that the table corruption is a result of the server dying. Otherwise, damage may occur during normal operation. This is a flaw. You should try to create a reproducible test case that demonstrates this problem.