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

by on July 1, 2010 · 1 comment· LAST UPDATED July 1, 2010

in

I'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

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 1 comment… read it below or add one }

1 Shashank January 19, 2012 at 6:53 am

I have created a video blog using drupal…recently I deleted duplicate entries in DB and it broke…I am getting following errors…

User warning: Incorrect key file for table '/var/lib/mysql/tmp/#sql_3567_0.MYI'; try to repair it query: SELECT DISTINCT node.nid AS nid, node.title AS node_title, node_data_field_emvideo.field_emvideo_embed AS node_data_field_emvideo_field_emvideo_embed, node_data_field_emvideo.field_emvideo_value AS node_data_field_emvideo_field_emvideo_value, node_data_field_emvideo.field_emvideo_provider AS node_data_field_emvideo_field_emvideo_provider, node_data_field_emvideo.field_emvideo_data AS node_data_field_emvideo_field_emvideo_data, node_data_field_emvideo.field_emvideo_status AS node_data_field_emvideo_field_emvideo_status, node_data_field_emvideo.field_emvideo_version AS node_data_field_emvideo_field_emvideo_version, node_data_field_emvideo.field_emvideo_title AS node_data_field_emvideo_field_emvideo_title, node_data_field_emvideo.field_emvideo_description AS node_data_field_emvideo_field_emvideo_description, node_data_field_emvideo.field_emvideo_duration AS node_data_field_emvideo_field_emvideo_duration, node.type AS node_type, node.vid AS node_vid, node.created AS node_created, DATE_FORMAT((FROM_UNIXTIME(node.created) + INTERVAL -28800 SECOND), '%Y%m%d') AS node_created_day FROM node node LEFT JOIN content_field_emvideo node_data_field_emvideo ON node.vid = node_data_field_emvideo.vid INNER JOIN node_access na ON na.nid = node.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 0 AND na.realm = 'user_relationship_node_access_author'))) AND ( (node.status = 1) AND (node.type in ('video')) )ORDER BY node_created_day DESC LIMIT 0, 100 in _db_query() (line 141 of /home/ewingchu/public_html/includes/database.mysqli.inc).

What can be the reason and solution behind this….

Reply

Leave a Comment

Tagged as: , , , , , , , , , ,

Previous Faq:

Next Faq: