1 恢复方案1
使用MysqLdump --all--databases的备份进行恢复。
2 恢复方案2
2.1 源端MysqL版本
[root@MysqL57 ~]# MysqL -V
MysqL Ver 14.14 distrib 5.7.36, for linux-glibc2.12 (x86_64) using EditLine wrapper
[root@MysqL57 ~]# MysqL -v
Welcome to the MysqL monitor. Commands end with ; or \g.
Your MysqL connection id is 4
Server version: 5.7.36-log MysqL Community Server (GPL)
copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered Trademark of Oracle Corporation and/or its
affiliates. Other names may be Trademarks of their respective
owners.
Reading history-file /root/.MysqL_history
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MysqL> use testdb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MysqL> select count(*) from t1;
--------------
select count(*) from t1
--------------
+----------+
| count(*) |
+----------+
| 17989991 |
+----------+
1 row in set (18.65 sec)
MysqL> flush table t1 for export;
--------------
flush table t1 for export
--------------
2.2 在源端scp数据
在源端口拷贝数据或者将数据拷贝到对应的备份带库
[root@MysqL57 testdb]# scp t1.ibd 192.168.56.88:/data/testdb
The authenticity of host '192.168.56.88 (192.168.56.88)' can't be established.
ECDSA key fingerprint is SHA256:kbb/xaKinLr3YzSaqvkSuYr2x4MgX50QhnIPvZH6bcI.
ECDSA key fingerprint is MD5:67:a9:14:9d:8c:8b:35:8c:48:65:eb:ea:61:20:7b:92.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.56.88' (ECDSA) to the list of kNown hosts.
root@192.168.56.88's password:
t1.ibd 100% 964MB 29.1MB/s 00:33
[root@MysqL57 testdb]# scp t1.cfg 192.168.56.88:/data/testdb
root@192.168.56.88's password:
t1.cfg 100% 504 173.9KB/s 00:00
2.3 目标端创建t1表
MysqL> create table t1 (id int,name varchar(10));
Query OK, 0 rows affected (0.03 sec)
MysqL> ALTER TABLE t1 discard tablespace;
Query OK, 0 rows affected (0.02 sec)
[root@MysqL8 testdb]# chown MysqL.MysqL t1.*
2.4 然后回到原数据库执行解释操作,再查看,已经没有 .cfg文件了,所以一定确定scp完了后再解锁:
MysqL> unlock tables;
2.5 查看cfg文件是否已经没有了
2.6 目的库执行导入表空间命令,然后查看表数据
ALTER TABLE t1 IMPORT TABLESPACE;