欢送来到 GreatSQL社区分享的MySQL技术文章,如有疑难或想学习的内容,能够在下方评论区留言,看到后会进行解答
  • GreatSQL社区原创内容未经受权不得随便应用,转载请分割小编并注明起源。

试验场景

GreatSQL 8.0.25 InnoDB

1.备份,导出单表, test.t_user

/usr/bin/xtrabackup -uroot -p'GreatSQL' -S /data/GreatSQL/mysql.sock --tables='test.t_user' --backup --target-dir=/data/backup

2.复原备份

xtrabackup --prepare --export --target-dir=/data/backup

3.建测试表

[root@GreatSQL][test02]>CREATE TABLE `t_user` (    ->   `id` bigint NOT NULL AUTO_INCREMENT,    ->   `name` varchar(255) DEFAULT NULL,    ->   `age` tinyint DEFAULT NULL,    ->   `create_time` datetime DEFAULT NULL,    ->   `update_time` datetime DEFAULT NULL,    ->   PRIMARY KEY (`id`),    ->   KEY `idx_name` (`name`),    ->   KEY `idx_age` (`age`)    -> ) ENGINE=InnoDB AUTO_INCREMENT=1091002 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;Query OK, 0 rows affected (0.16 sec)

4.卸载新表表空间

[root@GreatSQL][test02]>ALTER table t_user discard tablespace;Query OK, 0 rows affected (0.11 sec)

5.拷贝备份的t_user文件

[root@localhost test]# cd /data/backup/test/[root@localhost test2]# cp * /data/GreatSQL/test02/[root@localhost test2]# ll-rw-r--r-- 1 root root      964 Nov 24 04:12 t_user.cfg-rw-r----- 1 root root 18874368 Nov 24 04:10 t_user.ibd

6.挂载新表表空间

[root@GreatSQL][test02]>ALTER TABLE t_user import tablespace;Query OK, 0 rows affected, 1 warning (0.47 sec)

7.查问复原数据

[root@GreatSQL][test02]>select count(*) from test02.t_user;+----------+| count(*) |+----------+|    91002 |+----------+1 row in set (0.10 sec)# 旧表的数据[root@GreatSQL][test02]>select count(*) from test.t_user;+----------+| count(*) |+----------+|    91002 |+----------+1 row in set (0.07 sec)(Wed Nov 24 21:35:57 2021)[root@GreatSQL][test02]>

Enjoy GreatSQL :)

文章举荐:

技术分享 | MGR最佳实际(MGR Best Practice)
https://mp.weixin.qq.com/s/66...

技术分享 | 万里数据库MGR Bug修复之路
https://mp.weixin.qq.com/s/Ia...

Macos零碎编译percona及局部函数在Macos零碎上运算差别
https://mp.weixin.qq.com/s/jA...

技术分享 | 利用systemd治理MySQL单机多实例
https://mp.weixin.qq.com/s/iJ...

产品 | GreatSQL,打造更好的MGR生态
https://mp.weixin.qq.com/s/By...

产品 | GreatSQL MGR优化参考
https://mp.weixin.qq.com/s/5m...

对于 GreatSQL

GreatSQL是由万里数据库保护的MySQL分支,专一于晋升MGR可靠性及性能,反对InnoDB并行查问个性,是实用于金融级利用的MySQL分支版本。

Gitee:
https://gitee.com/GreatSQL/Gr...

GitHub:
https://github.com/GreatSQL/G...

微信&QQ群:

可搜寻增加GreatSQL社区助手微信好友,发送验证信息“加群”退出GreatSQL/MGR交换微信群

QQ群:533341697
微信小助手:wanlidbc

本文由博客一文多发平台 OpenWrite 公布!