Use this MySQL statement to repair corrupted MyISAM tables.


Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

    table[, ...] [QUICK] [EXTENDED] [USE_FRM]


Use this statement to repair corrupted MyISAM tables. Multiple tables may be given in a comma-separated list. To prevent this statement from recording its activities in the binary log file, give the NO_WRITE_TO_BINLOG keyword or its LOCAL alias. The QUICK keyword instructs MySQL to repair the table indexes only. The EXTENDED keyword rebuilds the indexes one row at a time. This option takes longer, but can be more effective, especially with rows containing duplicate keys.

Before running this statement, make a backup of the table. If a table continues to have problems, there may be other problems (e.g., filesystem problems) that you should consider.


Here is an example of this statement:


| Table                | Op     | Msg_type | Msg_text |
| | repair | status   | OK       |

In this example, the repair was successful. This is indicated by the OK in the Msg_text field. If it were unsuccessful, you could try the USE_FRM option with this statement. This option will create a new index file (.MYI) using the table schema file (.frm). It won't be able to determine the current value for AUTO_INCREMENT columns or for DELETE LINK, so it shouldn't be used unless the original .MYI file is lost. Incidentally, if the MySQL server dies while the REPAIR TABLE statement is running, you should run the statement again as soon as the server is back up, before running any other SQL statements.