Repairing a MySQL table
Sometimes it is necessary to run a repair on a corrupted table in MySQL if (for example) the database was interrupted during a write operation.
Normally you can do this using MySQLCheck, i.e.
mysqlcheck -u root -pSYXt1fI5zO -r micstats
Which will repair all tables in the micstats database. Sometimes, however, this will not work and you receive the following output:
mysqlcheck: [Warning] Using a password on the command line interface can be insecure.
micstats.audit OK
micstats.oldstats OK
micstats.schema_version OK
micstats.stats
Error : Incorrect key file for table 'stats'; try to repair it
error : Corrupt
micstats.taskgroups OK
micstats.tasklogs OK
micstats.taskruns OK
micstats.tmplastruns OK
In this case it is execute MySQL commands directly as follows:
mysql -u root -pSYXt1fI5zO
Followed by:
mysql> use micstats;
Database changed
mysql> repair table stats use_frm;
+----------------+--------+----------+-------------------------------------------+
| Table | Op | Msg_type | Msg_text |
+----------------+--------+----------+-------------------------------------------+
| micstats.stats | repair | warning | Number of rows changed from 0 to 65587097 |
| micstats.stats | repair | status | OK |
+----------------+--------+----------+-------------------------------------------+
2 rows in set (2 hours 10 min 51.45 sec)
Note that this will not work with myisamchk, so in terms of MOVEit, is not relevant for version 13 and later (where MySQL version and format is changed)
The ‘use_ftm’ option on the repair basically tells MySQL to ignore the .myi file, where the corruption is likely and instead recreate it based upon the .myd file