堂Di

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
> I'm trying to do a recover on a table for a client, with the following message
>
> root@falcon:~# mysqldump -u root -pXXXXXXX database
> -- MySQL dump 10.13  Distrib 5.1.30, for pc-linux-gnu (i686)
> --
> -- Host: localhost    Database: database
> -- ------------------------------------------------------
> -- Server version       5.1.30
>
> /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
> /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
> /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
> /*!40101 SET NAMES utf8 */;
> /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
> /*!40103 SET TIME_ZONE='+00:00' */;
> /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
> /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
> /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
> /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
> mysqldump: Got error: 1034: Incorrect key file for table 'table1'; try to repair it
> when using LOCK TABLES
> root@falcon:~#
>
> I'm trying recover with
>
> mysql> check table table1;
>
> +-----------------+-------+----------+-----------------------------------------------------------+
> | Table           |
> Op    | Msg_type |
> Msg_text                                                 
> |
>
> +-----------------+-------+----------+-----------------------------------------------------------+
> | database.table1 | check | Error    | Incorrect key file for table
> 'table1'; try to repair it |
> | database.table1 | check | error    |
> Corrupt                                                  
> |
>
> +-----------------+-------+----------+-----------------------------------------------------------+
> 2 rows in set (0.00 sec)
>
> mysql> repair table table1;
>
> +-----------------+--------+----------+-----------------------------------------------------------+
> | Table           |
> Op     | Msg_type |
> Msg_text                                                 
> |
>
> +-----------------+--------+----------+-----------------------------------------------------------+
> | database.table1 | repair | Error    | Incorrect key file for table
> 'table1'; try to repair it |
> | database.table1 | repair | error    |
> Corrupt                                                  
> |
>
> +-----------------+--------+----------+-----------------------------------------------------------+
> 2 rows in set (0.00 sec)
>
> mysql> lock table table1 write;
> ERROR 1034 (HY000): Incorrect key file for table 'table1'; try to repair it
> mysql>
>
>
> Trying repair with myisamchk and mysqlcheck
>
> root@Falcon:~# mysqlcheck -r database table1 -u root -pXXXX database.table1
> Error    : Incorrect key file for table 'table1'; try to repair it
> error    : Corrupt
> root@falcon:~#
>
> root@Falcon:~# cd /data/mysql/database
> root@Falcon:/data/mysql/database# myisamchk -r *.MYI
> - recovering (with sort) MyISAM-table 'table1.MYI'
> Data records: 0
> - Fixing index 1
>
> ---------
>
> Any idea.

Try to start with MySQL advices for such cases:
http://dev.mysql.com/doc/refman/5.6/en/myisam-repair.html
posted on 2014-04-21 15:51  堂Di  阅读(1775)  评论(0编辑  收藏  举报