/usr/libexec/mysqld: Incorrect key file for table ‘./DBNAME/TABLE_NAME.MYI’; Try To Repair It Error and Solution

‘m getting the following error in my mysql.log file:

100630 2:03:39 [ERROR] /usr/libexec/mysqld: Incorrect key file for table ‘./app2_db/aix_data_user.MYI’; try to repair it

How do I fix this error and repair my table under UNIX or Linux operating systems?

There are two ways to fix this error and repair mysql table.

Method # 1: Use MySQL Command Line

Login as root user, enter (app2_db is database name):
$ mysql -u root -p app2_db

To check table called aix_data_user, enter at the following mysql> prompt:
mysql> check table aix_data_user;
Sample outputs:

+---------------------+-------+----------+----------------------------------------------------------+
| Table               | Op    | Msg_type | Msg_text                                                 |
+---------------------+-------+----------+----------------------------------------------------------+
| table aix_data_user | check | warning  | Table is marked as crashed                               |
| table aix_data_user | check | warning  | 2 clients are using or haven't closed the table properly |
| table aix_data_user | check | error    | record delete-link-chain corrupted                       |
| table aix_data_user | check | error    | Corrupt                                                  |
+---------------------+-------+----------+----------------------------------------------------------+
4 rows in set (0.00 sec)
WARNING! It is best to make a backup of a table before performing a table repair operation; under some circumstances the operation might cause data loss. Possible causes include but are not limited to file system errors.

Type the following sql command to repair the aix_data_user table, enter:
mysql> repair table aix_data_user;
Sample outputs:

+---------------------+--------+----------+----------+
| Table               | Op     | Msg_type | Msg_text |
+---------------------+--------+----------+----------+
| table aix_data_user | repair | status   | OK       |
+---------------------+--------+----------+----------+
1 row in set (0.00 sec)

Option #2: Use mysqlcheck Command

The mysqlcheck command is used to checks, repairs, optimizes, and analyzes mysql tables. The general syntax is as follows:

mysqlcheck [options] db_name [tables]
mysqlcheck -u userName -p db_name table1

To check aix_data_user table, enter:
$ mysqlcheck -u root -p app2_db aix_data_user
Sample outputs:

Enter password:
aix_data_user                     OK

To repair the table pass the –auto-repair option to mysqlcheck command:
$ mysqlcheck --auto-repair -u root -p app2_db aix_data_user

No comments yet.