How to repair MySQL MyISAM tables?

This article describes the steps taken to repair a MyISAM table.

  1. Run myisamchk while the database is shut down. This tool checks, repairs and optimizes tables.
  2. Run the mysqlcheck tool, this can be ran while the database is in operation if needed.
  3. Login to the database with the root user and run the commands:

mysql> __optimize table tablename;
mysql> __analyze table tablename;
mysql> __repair table tablename;

These should clear up any issues with MyISAM tables. For more information, see the official MySQL documentation.