今天查询mysql的时候,报这样的错误,Incorrect key file for table './tg/dxad.MYI'; try to repair it. mysql表损坏的情况是很少见的,下面的方法适用于myisam,其他存储引擎,不知道能不能这样修复。
1,myisamchk修改表
[root@localhost tg]# myisamchk -of ./dxad.MYI //修复第一步 - recovering (with keycache) MyISAM-table './dxad.MYI' Data records: 12597637 Found block that points outside data file at 1630252996 Data records: 12597456 [root@localhost tg]# myisamchk -r ./dxad.MYI //修复第二步 - recovering (with sort) MyISAM-table './dxad.MYI' Data records: 12597456 - Fixing index 1 [root@localhost tg]# myisamchk ./dxad.MYI //修复第三步 Checking MyISAM file: ./dxad.MYI Data records: 12597456 Deleted blocks: 0 - check file-size - check record delete-chain - check key delete-chain - check index reference - check data record references index: 1 - check record links
myisamchk带的参数,可以用man看一下。操作后重新启动一下数据库。
[root@localhost tg]# /etc/init.d/mysqld restart
这样操作后,还是有问题,会报 #145 - Table "XXXXX" is marked as crashed and should be repaired。如下图:
2,命令行下repair修复表
mysql> repair table dxad; //dxad是表名
如下图
到这儿,myisam表损坏就修复好了。
转载请注明
作者:海底苍鹰
地址:http://blog.51yip.com/mysql/1457.html
你确定只用 “2,命令行下repair修复表” 不行吗,还需要前面的步骤?