2017-06-04 48 views
0

我的第一个问题在stackoverflow,所以我希望我已遵循所有的指导方针。MySQL错误密钥文件不正确。 myisamchk修复工作,但表腐败很快

我有一个数字海洋液滴MySql数据库的网站。

我发现mysql已停止运行,查找后发现损坏的表。用myisamchk -r修复后,我认为问题解决了。但是它一直在发生。我改变innodb_buffer_pool_size = 20M in my.cnf和创造上/dev/vda/一些自由空间阅读本MySQL, Error 126: Incorrect key file for table

Filesystem  1K-blocks  Used Available Use% Mounted on 
udev    239664  4 239660 1% /dev 
tmpfs    50176  380  49796 1% /run 
/dev/vda1  20511356 12346408 7099992 64%/
none     4  0   4 0% /sys/fs/cgroup 
none    5120  0  5120 0% /run/lock 
none    250872  0 250872 0% /run/shm 

后,我有这些错误了MySQL/error.log中

[ERROR] /usr/sbin/mysqld: Incorrect key file for table './websitename/wp_options.MYI'; try to repair it 
[ERROR] Got an error from thread_id=178, /build/mysql-5.5-heGK82/mysql-5.5-5.5.55/storage/myisam/mi_update.c:226 
[ERROR] MySQL thread id 178, OS thread handle 0x7f4544010700, query id 69124 localhost th3489075 Updating 

当我对损坏的表我跑myisamchk db_name.MYI得到

Checking MyISAM file: wp_options.MYI 
Data records:  375 Deleted blocks:  0 
myisamchk: warning: Table is marked as crashed 
myisamchk: warning: 1 client is using or hasn't closed the table properly 
- check file-size  
myisamchk: error: Size of datafile is: 1059228   Should be: 1059276 
- check record delete-chain 
- check key delete-chain 
- check index reference 
- check data record references index: 1 
- check data record references index: 2 
- check record links 
myisamchk: error: Keypointers and record positions doesn't match 
myisamchk: warning: Found  375 key parts. Should be: 377 
MyISAM-table 'wp_options.MYI' is corrupted 
Fix it using switch "-r" or "-o" 

修复表myisamchk -r or -o选项似乎运行工作myisamchk *.MYI立即报告没有问题,但稍后它返回上述错误。

我有数据库的各种备份,但我不确定它们与现有的不同。

我明白如果mysql正在运行,会发生警告myisamchk: warning: 1 client is using or hasn't closed the table properly

当mysql停止时myisamchk *.MYI报告都可以,但mysql仍然崩溃。

回答

0

每当mysqld发生电源故障或其他突然中断时,MyISAM表可能会损坏。这是切换到InnoDB的一个强有力的理由,InnoDB更好地保护自己并在重启时自动修复。

同时,您可以尝试尝试OPTIMIZE TABLE作为强制重建表的一种方法。这可能会或可能不会丢失似乎丢失的数据,但它会可能摆脱错误消息,直到下一次崩溃。

+0

谢谢里克,是的,我听说Innodb更健壮,有些事情要牢记未来。今天和一个伴侣聊天,他建议倾销数据库并导入它。到目前为止,这是没有错误的运行。我也会记住OPTIMIZE TABLE方法。 – r4debe

相关问题