mysql frm ibd 创建表_如何仅使用ibdata和* .ibd文件为MySQL InnoDB表重新创建FRM文件?...

编辑:我创建了一个简单的脚本,执行下面描述的所有步骤:

https://ourstickys.com/recover.sh

I have recovered my MySQL 5.5 *.ibd and *.frm files with using MySQL Utilites and MariaDB 10.

1) Generating Create SQLs.

You can get your create sql's from frm file. You must use : https://dev.mysql.com/doc/mysql-utilities/1.5/en/mysqlfrm.html

shell> mysqlfrm --server=root:pass@localhost:3306 c:\MY\t1.frm --port=3310

Other way you may have your create sql's.

2) Create Your Tables

Create your tables on the database.

3) alter table xxx discard tablespace

Discard your tables which do you want to replace your *.ibd files.

4) Copy your *.ibd files (MySQL Or MariaDB) to MariaDB's data path

First i try to use MySQL 5.5 and 5.6 to restrore, but database crashes and immediately stops about tablespace id broken error. (ERROR 1030 (HY000): Got error -1 from storage engine)

After i have used MariaDB 10.1.8, and i have succesfully recovered my data.

5) alter table xxx import tablespace

When you run this statement, MariaDB warns about file but its not important than to recover your data :) Database still continues and you can see your data.

I hope this information will helpful for you.

我还发现了一种使用dbsake获取CREATE TABLE的更快方法:

curl -s http://get.dbsake.net > dbsake

chmod u+x dbsake

然后:

#only one table

./dbsake frmdump /path/to/table.frm > recover.sql

#multiple tables

./dbsake frmdump /path/to/*.frm > recover.sql

其次是:

mysql -uUSER -p recover_db < recover.sql

如果您愿意,也可以在一个班轮中执行:

./dbsake frmdump /path/to/*.frm | mysql -uUSER -p recover_db

此时,您可以按照上述第3点的说明进行操作.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值