如何恢复 MySQL 数据库:文件中的信息不正确:'./xxx.frm'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2314249/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 15:21:34  来源:igfitidea点击:

How to recover a MySQL database: Incorrect information in file: './xxx.frm'

mysqldisaster-recovery

提问by Paul Go

A very important database has gone corrupt that was sitting on server at a shared web host, and I didn't back up. The table contains a large list of very important email addresses. I can get a table listing, but if I open any of the tables with Navicat or phpMyAdmin, I get the following error:

一个非常重要的数据库已损坏,该数据库位于共享 Web 主机的服务器上,我没有备份。该表包含非常重要的电子邮件地址的大列表。我可以获得表格列表,但是如果我使用 Navicat 或 phpMyAdmin 打开任何表格,我会收到以下错误:

Incorrect information in file: './the-table-name.frm'

文件中的信息不正确:“./the-table-name.frm”

I was able to get a hold of the .frm files associated with the database from the web host.

我能够从 Web 主机中获取与数据库关联的 .frm 文件。

There is other data in there, but if I could at least get the email addresses, I would be alright.

那里还有其他数据,但如果我至少能得到电子邮件地址,我会没事的。

How do I recover this database? I would be willing to pay somebody to fix this.

如何恢复这个数据库?我愿意花钱请人来解决这个问题。

回答by hobodave

This belongs on serverfault.

这属于服务器故障。

First, .FRM files contain noneof your "data". They are simply the definition of the table.

首先,.FRM 文件不包含您的任何“数据”。它们只是表的定义。

If allof the following are true:

如果以下所有情况都为真:

  • The table is using the MyISAM storage engine
  • You know the CREATE TABLEstatement required to recreate the table
  • 该表使用的是 MyISAM 存储引擎
  • 您知道CREATE TABLE重新创建表所需的语句

Then, do the following:

然后,执行以下操作:

  1. Stop MySQL
  2. Backup your table_name.frm, table_name.MYI, table_name.MYD files
  3. Delete them from your mysql data directory (/var/lib/mysql usually)
  4. Start MySQL
  5. CREATE the table again
  6. Stop MySQL
  7. Copy the .MYD and .MYI files back into the datadir, replacing the ones there.
  8. Start MySQL
  9. ???
  10. Profit
  1. 停止 MySQL
  2. 备份您的 table_name.frm、table_name.MYI、table_name.MYD 文件
  3. 从您的 mysql 数据目录中删除它们(通常为 /var/lib/mysql)
  4. 启动 MySQL
  5. 再次创建表
  6. 停止 MySQL
  7. 将 .MYD 和 .MYI 文件复制回 datadir,替换那里的文件。
  8. 启动 MySQL
  9. ???
  10. 利润

回答by Addo Solutions

I had a similar issue, it turns out the MySQL InnoDB engine was turned off (I was able to check via phpMyAdmin, a bash pro could tell you how to do it other ways). in my case, it was a simple as restarting MySQL, but you may want to check your config if something changed there.

我遇到了类似的问题,结果是 MySQL InnoDB 引擎已关闭(我可以通过 phpMyAdmin 检查,bash 专家可以告诉您如何通过其他方式进行操作)。就我而言,这就像重新启动 MySQL 一样简单,但是如果那里发生了某些变化,您可能需要检查您的配置。

回答by jsonx

You may try the following commands: CHECK TABLE tablename

您可以尝试以下命令:CHECK TABLE tablename

If this gives "corrupt" message try:

如果这给出“损坏”消息,请尝试:

REPAIR TABLE tablename

修复表表名

Actually these are didn't solve my similar problem but they may be useful for somebody.

实际上,这些并没有解决我的类似问题,但它们可能对某些人有用。