MySQL Repair Table

Profile picture for user arilio666

Occasionally tables from MySQL become corrupted, which leads to the loss of readability, and when attempted to read from this corrupted table might result in the server crashing. While this happens, the REPAIR TABLE command repairs a corrupted table and fixes the issue sometimes.

Although note that this statement requires SELECT and INSERT privileges for the table. In the average case, the REPAIR TABLE is not needed to run until a disaster strikes. This statement is likely to get all our data back.

MySQL Repair Table Syntax

REPAIR TABLE table_name;

Repair Table Storage Engine

  • REPAIR TABLE works for MyISAM, ARCHIVE, and CSV tables.
  • The statement does not work with views.

Repair Table Options

  1. NO_WRITE_TO_BINLOG or LOCAL: This option is used to suppress logging to the binary log.
  2. QUICK: This option repairs only the index file and not the data file.
  3. EXTENDED: When using this option, MySQL creates the index row by row instead of creating one index at a time with sorting.
  4. USE_FRM:  This is used when the .MYI index file is missing or its header is corrupted.
Tags