如何从 .ibd 文件重新创建 MySQL InnoDB 表?

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

How do I re-create a MySQL InnoDB table from an .ibd file?

mysqlinnodbdisaster-recovery

提问by knorv

Assume that the following MySQL files have been restored from a backup tape:

假设以下 MySQL 文件已从备份磁带中恢复:

  • tablename.frm
  • tablename.ibd
  • tablename.frm
  • tablename.ibd

Furthermore, assume that the MySQL installation was running with innodb_file_per_tableand that the database was cleanly shutdown with mysqladmin shutdown.

此外,假设 MySQL 安装正在运行,innodb_file_per_table并且数据库使用mysqladmin shutdown.

Given a fresh install of the same MySQL version that the restored MySQL files were taken from, how do I import the data from tablename.ibd/tablename.frminto this new install?

给定一个新鲜的同一MySQL版本安装的MySQL的恢复文件从拍摄,我该如何将数据导入from tablename.ibd/tablename.frm到这个新的安装?

回答by Snehasish Sarkar

Similar thing is answered here. please have a look https://stackoverflow.com/a/10943833/3985205

类似的事情在这里回答。请看看 https://stackoverflow.com/a/10943833/3985205

Yes this is possible. It is not enough you just copy the .frm files to the to the databse folder but you also need to copy the ib_logfiles and ibdata file into your data folder. I have just copy the .frm files and copy those files and just restart the server and my database is restored.

是的,这是可能的。仅将 .frm 文件复制到 databse 文件夹还不够,还需要将 ib_logfiles 和 ibdata 文件复制到数据文件夹中。我刚刚复制了 .frm 文件并复制了这些文件,然后重新启动服务器,我的数据库就恢复了。

回答by Jin Lin

I posted the correct solution when you lost ib_logfilesand ibdatafile and you have only .frmand .idbfiles.

当您丢失ib_logfilesibdata归档而您只有.frm.idb文件时,我发布了正确的解决方案。

Please take a look at my comment on this link:

Restore table structure from frm and ibd files

请看一下我对这个链接的评论:

从 frm 和 ibd 文件恢复表结构

This will work for you, too.

这对你也有用。

Thank you.

谢谢你。

回答by Sergiy Tytarenko

You must bring the table into the tablespace:

您必须将表带入表空间:

https://www.percona.com/doc/percona-xtrabackup/2.2/innobackupex/restoring_individual_tables_ibk.html

https://www.percona.com/doc/percona-xtrabackup/2.2/innobackupex/restoring_individual_tables_ibk.html

ALTER TABLE mydatabase.tablename IMPORT TABLESPACE;

There is also a exp/cfg file you must have.

您还必须拥有一个 exp/cfg 文件。

回答by Nandit

This not may work in all cases. But yes it is working in some case...

这并非在所有情况下都有效。但是是的,它在某些情况下有效......

First stop all the services related to wamp or xampp which you use.

首先停止所有与您使用的 wamp 或 xampp 相关的服务。

Then copy and past the tablename.frm, tablename.ibd

然后复制并粘贴tablename.frm, tablename.ibd

files under mysql/data/DATABASE NAME FOLDER. then start all the services again. the tablet created under that DB.

mysql/data/DATABASE NAME FOLDER 下的文件。然后再次启动所有服务。在该数据库下创建的平板电脑。