MySQL 如何修复“错误 130 (HY000):文件格式不正确”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4297592/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to fix "ERROR 130 (HY000): Incorrect file format"
提问by Kohan95
I have a problem with my database when I made a query on one of my tables I get this error message
当我对我的一个表进行查询时,我的数据库出现问题我收到此错误消息
ERROR 130 (HY000): Incorrect file format
ERROR 130 (HY000):文件格式不正确
please how to fix it?
请问怎么修?
采纳答案by Haim Evgi
try repairtable , another good article
The relevant section from the first link:
第一个链接的相关部分:
MySQL database allows you to define a different MySQL storage engine for different tables. The storage engine is the engine used to store and retrieve data. Most popular storage engines are MyISAM and InnoDB.
MyISAM tables -will- get corrupted eventually. This is a fact of life.
Luckily, in most cases, MyISAM table corruption is easy to fix.
To fix a single table, connect to your MySQL database and issue a:
repair TABLENAME
To fix everything, go with:
/usr/local/mysql/bin/mysqlcheck --all-databases -uUSERNAME -pPASSWORD -r
A lot of times, MyISAM tables will get corrupt and you won't even know about it unless you review the log files.
I highly suggest you add this line to your /etc/my.cnf config file. It will automatically fix MyISAM tables as soon as they become corrupt:
[mysqld] myisam-recover=backup,force
MySQL 数据库允许您为不同的表定义不同的 MySQL 存储引擎。存储引擎是用于存储和检索数据的引擎。最流行的存储引擎是 MyISAM 和 InnoDB。
MyISAM 表最终会损坏。这是生活中的事实。
幸运的是,在大多数情况下,MyISAM 表损坏很容易修复。
要修复单个表,请连接到您的 MySQL 数据库并发出:
repair TABLENAME
要解决所有问题,请使用:
/usr/local/mysql/bin/mysqlcheck --all-databases -uUSERNAME -pPASSWORD -r
很多时候,MyISAM 表会损坏,除非您查看日志文件,否则您甚至不会知道它。
我强烈建议您将此行添加到您的 /etc/my.cnf 配置文件中。一旦 MyISAM 表损坏,它会自动修复它们:
[mysqld] myisam-recover=backup,force
回答by programer
Type
repair table 'table_name' use_frm
in SQL editor and execute it. This repairs the index. Good working...
键入
repair table 'table_name' use_frm
SQL 编辑器并执行它。这将修复索引。干得好...
回答by Bell
Let me explain the details that I tried.
让我解释一下我尝试过的细节。
I got this "Incorrect file format" after performing the mysqldump. It's similar to like we have the issue in the server startup/querying the tables.
执行 mysqldump 后,我得到了这个“文件格式不正确”。这类似于我们在服务器启动/查询表中遇到的问题。
I went to the mysql/data/yourdatabasename folder and checked the table. (For MYISAM types of tables, we have .frm, .MYI, .MYD.) I found that the table has only tablename.frm only. So I just moved the frm part alone as it is not needed anymore because of the lack of .MYI and .MYD files. I did the same for some more tables that encountered with the incorrect file format problem.
我去了 mysql/data/yourdatabasename 文件夹并检查了表。(对于 MYISAM 类型的表,我们有 .frm、.MYI、.MYD。)我发现该表只有 tablename.frm。所以我只是单独移动了 frm 部分,因为它不再需要了,因为缺少 .MYI 和 .MYD 文件。我对一些遇到不正确文件格式问题的表做了同样的处理。
In my case, tables that I removed are not MYI/MYD and some of the tables are not having data. Please make sure of both the cases before you do any of this. If you do for the data available table, you will end up with the data loss for the tables you remove.
就我而言,我删除的表不是 MYI/MYD,并且某些表没有数据。在您执行任何操作之前,请确保这两种情况。如果您对可用数据表执行此操作,最终将导致您删除的表的数据丢失。