mysql出現(xiàn)“Incorrect key file for table”解決辦法
今天mysql突然出現(xiàn)以下錯(cuò)誤:
mysql> select * from test;
ERROR 1034 (HY000): Incorrect key file for table ‘test’; try to repair it
首先通過(guò)repair table修復(fù):
mysql> repair table test;
+—————+——–+———-+———————————————————+
| Table | Op | Msg_type | Msg_text |
+—————+——–+———-+———————————————————+
| test.test | repair | Error | Incorrect key file for table ‘test’; try to repair it |
| test.test | repair | error | Corrupt
如果還是沒(méi)用,運(yùn)行下面命令
mysql> repair table test USE_FRM;
+—————+——–+———-+———————————————————+
| Table | Op | Msg_type | Msg_text |
+—————+——–+———-+———————————————————+
| test.test | repair | Error |Number of rows changed from 0 to 110423 |
| test.test | repair | status | OK
按理應(yīng)該可以了。
如果還是沒(méi)用肝集,則退出mysql虐先,執(zhí)行如下修復(fù)動(dòng)作:
myisamchk -of /var/lib/mysql/test/test.MYI
myisamchk -r /var/lib/mysql/test/test.MYI
myisamchk safe-recover /var/lib/mysql/test/test.MYI
再重啟mysql后應(yīng)該可以正常了。