Home  >  Article  >  Database  >  repair table导致数据丢失_MySQL

repair table导致数据丢失_MySQL

WBOY
WBOYOriginal
2016-06-01 13:51:531305browse

       前天在本地测试机上,MySQL 5.1.43,MyISAM引擎,执行repair table的时候,导致数据丢失,特此记录,以前在MySQL5.0.32版本也遇到过同样的问题,所以在repair table前一定要备份。

       在执行repair table的前一晚,刚看了“宇航员的妻子”的电影,虽然是个烂片,但是其中的一句话印象很深刻:“太空总署告诉我,一定要有备份”,外行人都知道的简单的道理,我却没有做到,以此谨记。

       这个也是MySQL官方承认的bug,

http://bugs.mysql.com/bug.php?id=10437,

http://bugs.mysql.com/bug.php?id=1804

MySQL手册上也指出来了:

MySQL5.0 和MySQL5.1 ,

遇到同样的问题,我们该怎么规避这件事情呢?

使用myisamchk --safe-recover

还有一个牛人给我推荐了:OPTIMIZE LOCAL TABLE tablename; 这个命令的好处是对MyISAM和INNODB都起作用,呵呵,下次试试

经过测试MyISAM表遭到破坏后OPTIMIZE LOCAL TABLE tablename;是修复不了的,还是使用myisamchk --safe-recover 当然别忘记备份!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn