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

Posted: 0p in MySQL

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

How do I fix this error and repair my table.

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
==========================================================

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s