Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you recover from an "incorrect key file" with MySQL (InnoDB)?

Incorrect key file for table 'widgets'; try to repair it 

This is the error message MySQL gives me when attempting to apply a new index to an existing (very large) table. Of course when I follow the error message's suggestion of trying to repair it:

mysql> repair table widgets;
+-------------------+--------+----------+---------------------------------------------------------+
| Table             | Op     | Msg_type | Msg_text                                                |
+-------------------+--------+----------+---------------------------------------------------------+
| tedsdb.widgets    | repair | note     | The storage engine for the table doesn't support repair | 
+-------------------+--------+----------+---------------------------------------------------------+
1 row in set (0.00 sec)

What's my best course of action here (following the obvious full backup before tinkering)?

UPDATE: I created a new table (MyISAM) of the same schema, copied over all the records (insert into select), the changed the engine on the new table (InnoDB), renamed the corrupt table and renamed the new table, then tried again and got the same error.

like image 882
Teflon Ted Avatar asked Jun 22 '09 13:06

Teflon Ted


1 Answers

Looks like an old question, but I just ran into this problem. MySQL was writing out a temporary table to disk and the /tmp partition filled up.

like image 188
Edwin Knuth Avatar answered Oct 06 '22 00:10

Edwin Knuth