MySQL: #126 - Incorrect key file for table

Viewed 141804

I got the following error from a MySQL query.

#126 - Incorrect key file for table

I have not even declared a key for this table, but I do have indices. Does anyone know what could be the problem?

17 Answers

Try to run a repair command for each one of the tables involved in the query.

Use MySQL administrator, go to Catalog -> Select your Catalog -> Select a table -> Click the Maintenance button -> Repair -> Use FRM.

I got this message when writing to a table after reducing the ft_min_word_len (full text min word length). To solve it, re-create the index by repairing the table.

mysqlcheck -r -f  -uroot -p   --use_frm db_name

will normally do the trick

Came here searching for - "#1034 - Incorrect key file for table 'test'; try to repair it"

Seeing this caused by added a charset to an indexed Enum (might be the same with other fields) with Mysql 8.0.21.

CREATE TABLE `test` (
`enumVal` ENUM( 'val1' ) NOT NULL
) ENGINE = MYISAM;
ALTER TABLE `test` ADD INDEX ( `enumVal` );

ALTER TABLE  `test` CHANGE  `enumVal`  `enumVal` ENUM(  'val1') CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;

Solution using is to drop the index before the alter.

ALTER TABLE `test` ADD INDEX ( `enumVal` );
Related