MySQL: #126 - Incorrect key file for table

前端 未结 17 1937
臣服心动
臣服心动 2020-11-29 02:18

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 i

17条回答
  •  情话喂你
    2020-11-29 02:36

    Now of the other answers solved it for me. Turns out that renaming a column and an index in the same query caused the error.

    Not working:

    -- rename column and rename index
    ALTER TABLE `client_types`
        CHANGE `template_path` `path` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
        DROP INDEX client_types_template_path_unique,
        ADD UNIQUE INDEX `client_types_path_unique` (`path` ASC);
    

    Works (2 statements):

    -- rename column
    ALTER TABLE `client_types`
        CHANGE `template_path` `path` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
    -- rename index
    ALTER TABLE `client_types`
        DROP INDEX client_types_template_path_unique,
        ADD UNIQUE INDEX `client_types_path_unique` (`path` ASC);
    

    This was on MariaDB 10.0.20. There were no errors with the same query on MySQL 5.5.48.

提交回复
热议问题