首页 | 互联网 | IT动态 | IT培训 | Cisco | Windows | Linux | Java | .Net | Oracle | 软件测试 | C/C++ | 嵌入式开发 | 存储世界 | 服务器
网络设备 | IDC | 安全 | 求职招聘 | 数字网校 | 网页设计 | 平面设计 | 技术专题 | 电子书下载 | 教学视频 | 源码下载 | 搜索 | 博客 | 论坛
中国IT实验室Oracle频道
中国IT教育
Google
首页 入门基础 安装配置 体系架构 PLSQL 备份恢复 性能调优 开发技术 资讯动态 考试认证 下载 专题 讨论
您现在的位置: 中国IT实验室 >> Oracle >> 备份恢复 >> 正文

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

  使用MYISAM存储引擎,当创建一个表时,会出现三个文件:数据文件MYD,索引文件MYI,格式文件frm。当索引文件损坏时或者丢失时,可以用如下的方法进行修复。下面是实验过程。

   [mysql@testapp74 notify]$ mv message_ignore.MYI message_ignore.MYI.bak
  [mysql@testapp74 notify]$
  [mysql@testapp74 notify]$ mysqld_safe &
  [1] 26267
  [mysql@testapp74 notify]$ 080630 14:19:03 mysqld_safe Logging to '/usr/mysql_data/log/alert.log'.
  080630 14:19:03 mysqld_safe Starting mysqld daemon with databases from /usr/mysql_data/data
  [mysql@testapp74 notify]$
  [mysql@testapp74 notify]$
  [mysql@testapp74 notify]$
  [mysql@testapp74 notify]$ vi /usr/mysql_data/log/alert.log
  080630 14:18:14 [Note] /usr/sbin/mysqld: Normal shutdown
  080630 14:18:14 [Note] Event Scheduler: Purging the queue. 0 events
  080630 14:18:16 InnoDB: Starting shutdown...
  080630 14:18:19 InnoDB: Shutdown completed; log sequence number 162 783173592
  080630 14:18:19 [Note] /usr/sbin/mysqld: Shutdown complete
  080630 14:18:19 mysqld_safe mysqld from pid file /usr/mysql_data/data/testapp74.pid ended
  080630 14:19:03 mysqld_safe Starting mysqld daemon with databases from /usr/mysql_data/data
  080630 14:19:03 InnoDB: Started; log sequence number 162 783173592
  080630 14:19:03 [Note] Event Scheduler: Loaded 0 events
  080630 14:19:03 [Note] /usr/sbin/mysqld: ready for connections.
  Version: '5.1.23-rc-community' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Edition (GPL)

  从上面可以看出,当一个表出现问题,mysql的警告日志并没有任何的错误出现。

   [mysql@testapp74 notify]$ mysql -uroot
  Welcome to the MySQL monitor. Commands end with ; or \g.
  Your MySQL connection id is 4
  Server version: 5.1.23-rc-community MySQL Community Edition (GPL)
  Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  mysql> use notify
  Reading table information for completion of table and column names
  You can turn off this feature to get a quicker startup with -A
  Database changed
  mysql>
  mysql>
  mysql>
  mysql>
  mysql> select * from message_ignore limit 1; --当查询表时,会报错
  ERROR 1017 (HY000): Can't find file: 'message_ignore' (errno: 2)
  mysql> check table message_ignore;
  +-----------------------+-------+----------+----------------------------------------------+
  | Table | Op | Msg_type | Msg_text |
  +-----------------------+-------+----------+----------------------------------------------+
  | notify.message_ignore | check | Error | Can't find file: 'message_ignore' (errno: 2) |
  | notify.message_ignore | check | error | Corrupt |
  +-----------------------+-------+----------+----------------------------------------------+
  2 rows in set (0.03 sec)
  mysql>
  mysql> repair table message_ignore;
  +-----------------------+--------+----------+----------------------------------------------+
  | Table | Op | Msg_type | Msg_text |
  +-----------------------+--------+----------+----------------------------------------------+
  | notify.message_ignore | repair | Error | Can't find file: 'message_ignore' (errno: 2) |
  | notify.message_ignore | repair | error | Corrupt |
  +-----------------------+--------+----------+----------------------------------------------+
  2 rows in set (0.00 sec)

[1] [2] 下一页

【责编:michael】

中国IT教育

相关产品和培训
文章评论
 友情推荐链接
 认证培训
 专题推荐

 ·关于Java框架技术专题
 ·XML全攻略技术专题
 ·JAVA开源技术介绍专题
 ·Java嵌入式开发之J2ME技术专题
 ·超前体验 Oracle 11g的5个新特性…
 ·揭密使用VB.NET的五个实用技巧
 ·Oracle和SQL Server常用函数对比专题…
 ·展现C#世界 C#程序设计专题…
 ·Java入门 Tomcat的配置技巧精华专题…
 ·Oracle RMAN物理备份技术详解…
 今日更新
 社区讨论
 博客论点
 频道精选
 Oracle频道相关导航