一、安装mysqlfrm工具
下载路径:https://downloads.mysql.com/archives/utilities/
二、操作过程
1.新建临时数据库temp
2.将需要还原的表文件拷贝到“d:/temp"文件夹中
3.执行下面命令,生成建表语句,语句中会自动将文件夹名作为数据库名
mysqlfrm --server=root:密码@localhost:3306 "d:\temp" --port=3310 > temp_frm.sql
4.执行temp_frm.sql(可能需要先把文件中警告去掉,sql语句之间加上分号)
5.执行下面命令,生成丢弃表空间语句
mysql -uroot -p -hlocalhost -P3306 -e "select concat('alter table temp.',table_name,' discard tablespace; ') from information_schema.tables where table_schema='temp';" > temp_discard.sql
6.执行temp_discard.sql
7.拷贝原数据库表的.ibd文件至新数据库相应目录
8.执行下面命令,生成导入表空间语句
mysql -uroot -p -hlocalhost -P3306 -e "select concat('alter table temp.',table_name,' import tablespace; ') from information_schema.tables where table_schema='temp';" > temp_import.sql
9.执行temp_import.sql,数据恢复完成