Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 37.8Mb
PDF (A4) - 37.8Mb
PDF (RPM) - 36.4Mb
HTML Download (TGZ) - 9.9Mb
HTML Download (Zip) - 9.9Mb
HTML Download (RPM) - 8.6Mb
Man Pages (TGZ) - 209.5Kb
Man Pages (Zip) - 318.7Kb
Info (Gzip) - 3.5Mb
Info (Zip) - 3.5Mb
Excerpts from this Manual Corrupted MyISAM Tables

Even though the MyISAM table format is very reliable (all changes to a table made by an SQL statement are written before the statement returns), you can still get corrupted tables 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 turned off).

  • Hardware failures.

  • You are using an external program (such as myisamchk) to modify a table that is being modified by the server at the same time.

  • A software bug in the MySQL or MyISAM code.

Typical symptoms of a corrupt table are:

  • You get the following error while selecting data from the table:

    Incorrect key file for table: '...'. Try to repair it
  • Queries don't find rows in the table or return incomplete results.

You can check the health of a MyISAM table using the CHECK TABLE statement, and repair a corrupted MyISAM table with REPAIR TABLE. When mysqld is not running, you can also check or repair a table with the myisamchk command. See Section, “CHECK TABLE Syntax”, Section, “REPAIR TABLE Syntax”, and Section 4.6.3, “myisamchk — MyISAM Table-Maintenance Utility”.

If your tables become corrupted frequently, you should try to determine why this is happening. The most important thing to know is whether the table became corrupted as a result of a server crash. You can verify this easily by looking for a recent restarted mysqld message in the error log. If there is such a message, it is likely that table corruption is a result of the server dying. Otherwise, corruption may have occurred during normal operation. This is a bug. You should try to create a reproducible test case that demonstrates the problem. See Section B.5.3.3, “What to Do If MySQL Keeps Crashing”, and Section 28.5, “Debugging and Porting MySQL”.

User Comments
  Posted by NOT_FOUND NOT_FOUND on March 29, 2004
if you set

you should also set

if you use myisamchk
  Posted by Harel Malka on October 13, 2004
I ran into a case where a large myiasm table threw the above error when it was included inside a transaction (by mistake) along with other innoDB tables. A bunch of mass deletes were taking place, and the operation always ended with the table corrupted.
A quick conversion to innoDB solved the problem:

ALTER TABLE tablename TYPE=InnoDB;
  Posted by Cherry Austin on July 13, 2005
Thanks for that! I had a tiny MyISAM table but, all the same, queries were sometimes taking too long to execute & the container page wouldn't load properly. Changed to INNO-DB, problem cleared!
  Posted by Piotr SaÅ‚aciak on December 11, 2010
When You are using a trigger (or triggers) with Your MyISAM tables they may be "unrepairable" when they become corrupted. In such a case, You should physically delete all trigger files from database directory (eventually run DROP TRIGGER command), then run REPAIR statement and finally define Your trigger again.
Sign Up Login You must be logged in to post a comment.