恢复思路:
1、使用dbsake获取建表语句
https://github.com/abg/dbsake
2、使用mysql表传输功能
https://dev.mysql.com/doc/refman/8.0/en/innodb-table-import.html
恢复步骤:
1、根据github下载安装dbsake
root@ip-172-31-30-45:~# curl -s get.dbsake.net > dbsake root@ip-172-31-30-45:~# chmod u+x dbsake
2、获取 .frm 文件表结构,并到数据库中建表
root@ip-172-31-30-45:~# ./dbsake frmdump ./tt.frm -- -- Table structure for table `tt` -- Created with MySQL Version 5.7.34 -- CREATE TABLE `tt` ( `id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; root@ip-172-31-30-45:~#
mysql> CREATE TABLE `tt` (
-> `id` int(11) NOT NULL,
-> PRIMARY KEY (`id`)
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.01 sec)
mysql>
3、卸载tt 表
mysql> alter table tt discard tablespace; Query OK, 0 rows affected (0.00 sec)
4、拷贝 tt.ibd 到数据目录
root@ip-172-31-30-45:/usr/local/mysql57/data/ceshi# cp /root/tt.ibd /usr/local/mysql57/data/ceshi
5、导入 tt 表
mysql> alter table tt import tablespace; Query OK, 0 rows affected, 1 warning (0.03 sec)
6、查询数据
mysql> select * from tt; +----+ | id | +----+ | 2 | | 3 | | 4 | +----+ 3 rows in set (0.00 sec)