当前位置: > 数据库 > MySQL >

MYSQL表被损坏的解决 is marked as crashed and should be repaired

时间:2015-02-25 01:58来源:linux.it.net.cn 作者:IT
本机打了Win2003的SP2,在运行时,突然死机。

重启后,运行PHP程序,原来好好的,突然出现:Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

看看sql语句,没啥不正确呀。
去phpmyadmin中运行一下,晕,提示:
#126 - Incorrect key file for table '.\mobile\mobile.MYI'; try to repair it

使用其的检查表(CHECK TABLE `mobile`),提示确实有错误,正准备用修复表(REPAIR TABLE `mobile`),突然提示:

#145 - Table '.\mobile\mobile' is marked as crashed and should be repaired

...直接表损坏了:(

网上搜索一下,说是使用这句。


myisamchk -c -r *.MYI



C:\MySQL\data>myisamchk -c -r *.MYI
myisamchk: error: 22 when opening MyISAM-table '*.MYI'

C:\MySQL\bin>myisamchk mobile.MYI
myisamchk: error: File 'mobile.MYI' doesn't exist

想想,可能是它找不到文件吧。
于是
C:\MySQL\data>myisamchk -c -r c:/mysql/data/mobile/mobile.MYI
- recovering (with sort) MyISAM-table 'c:/mysql/data/mobile/mobile.MYI'
Data records: 104424
- Fixing index 1
- Fixing index 2
- Fixing index 3
Data records: 104430

哈,恢复!


      我的这个mysql安装在D:\Program Files\MySQL\MySQL Server 5.0\data\

D:\Program Files\MySQL\MySQL Server 5.0\bin>myisamchk -r D:\Program Files\MySQL
\MySQL Server 5.0\data\immw\products.MYI;

总是有问题...
说找不到文件

因为Program Files\MySQL\MySQL Server 5.0 用空格

后来用dir /x

知道Program Files 用这个表示:PROGRA~1

知道MySQL Server 5.0 用这个表示:MySQLS~1.0

D:\Program Files\MySQL\MySQL Server 5.0\bin>myisamchk -r D:\PROGRA~1\MySQL\MySQL
S~1.0\data\immw\products.MYI
- recovering (with sort) MyISAM-table 'D:\PROGRA~1\MySQL\MySQLS~1.0\data\immw\pr
oducts.MYI'
Data records: 154581
- Fixing index 1
- Fixing index 2
- Fixing index 3
- Fixing index 4
- Fixing index 5
- Fixing index 6



D:\Program Files\MySQL\MySQL Server 5.0\bin>




linux



myisamchk -c -r /var/lib/mysql/xxx/xxx.MYI


(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容