CTOCIO IT专家网

天极传媒 比特网 | 天极网 | IT专家网 | IT商网 | 52PK游戏网 | 手机天极 | IT分众 |
IT专家网搜索

数据库 | Oracle | DB2 | SQL Server | MySQL | 商业智能 | BI | DBA | Sybase| SQL Server 2008

您现在的位置: IT专家网 > 数据库子站 > 数据库技巧

MYISAM索引文件损坏的修复方法

作者: 丹臣,  出处:blog, 责任编辑: 李书琴, 
2008-07-11 10:26
  使用MYISAM存储引擎,当创建一个表时,会出现三个文件:数据文件MYD,索引文件MYI,格式文件frm。当索引文件损坏时或者丢失时,可以用如下的方法进行修复。本文介绍了实验过程。

  使用格式化文件frm重新创建索引文件


  mysql> repair table message_ignore USE_FRM;
  +-----------------------+--------+----------+----------+
  | Table | Op | Msg_type | Msg_text |
  +-----------------------+--------+----------+----------+
  | notify.message_ignore | repair | status | OK |
  +-----------------------+--------+----------+----------+
  1 row in set (0.02 sec)
  mysql>
  mysql> check table message_ignore;
  +-----------------------+-------+----------+----------+
  | Table | Op | Msg_type | Msg_text |
  +-----------------------+-------+----------+----------+
  | notify.message_ignore | check | status | OK |
  +-----------------------+-------+----------+----------+
  1 row in set (0.02 sec)

  修复后,数据可以正常查询


  mysql> select * from message_ignore limit 1;
  Empty set (0.00 sec)

  如果是格式化文件frm损坏,可以从slave拷贝过来即可,或者从备份中恢复。

  附录,在哪些情况下,myisam存储引擎的表容易损坏:

  14.1.4.1. Corrupted MyISAM Tables

  Even though the MyISAM table format is very reliable (all changes to a table made by an SQL statement are written before the statement returns), you can still get corrupted tables if any of the following events occur:

  •   The mysqld process is killed in the middle of a write.
  •   An unexpected computer shutdown occurs (for example, the computer is turned off).
  •   Hardware failures.
  •   You are using an external program (such as myisamchk) to modify a table that is being modified by the server at the same time.
  •   A software bug in the MySQL or MyISAM code.
共2页。 9 1 2

网友评论

笔名 
请您注意:遵守国家有关法律、法规,尊重网上道德,承担一切因您的行为而直接或间接引起的法律责任。    IT专家网友拥有管理笔名和留言的一切权利。
  • 周排行榜
  • 月排行榜

邮件订阅


    
天极服务 | 关于我们 | 网站律师 | 加入我们 | 联系我们 | 广告业务 | 友情链接 | 我要挑错
All Rights Reserved, Copyright 2004-2008, Ctocio.com.cn
渝ICP证B2-20030003号 如有意见请与我们联系 powered by 天极内容管理平台CMS4i