您的位置:首页 > 数据库 > MySQL

解决mysqldump 出现Incorrect key file for xxx; try to repair it

2014-04-21 15:51 525 查看
> 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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐