您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
这篇文章主要介绍了如何将MySQL的表数据全量导入clichhouse库中的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇如何将MySQL的表数据全量导入clichhouse库中文章都会有所收获,下面我们一起来看看吧。
tidb06 mysql5.7.32
tidb05 clickhouse20.8.3.18
tidb06库创建复制账户:
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'click_rep'@'172.16.0.246' identified by 'jwts996';flush privileges; Query OK, 0 rows affected, 1 warning (0.00 sec)
tidb06库创建测试库表test01.tb2并且写入测试数据:
CREATE TABLE `tb2` ( `id` int(8) NOT NULL AUTO_INCREMENT, `username` varchar(20) COLLATE utf8_unicode_ci NOT NULL, `password` varchar(20) COLLATE utf8_unicode_ci NOT NULL, `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', PRIMARY KEY (`id`) #主键ID ) ENGINE=innodb AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; INSERT INTO tb2(username,password,create_time) values('tomcat', 'xiaohuahua',now()); INSERT INTO tb2(username,password,create_time) values('java', 'xiaohuahua',now()); root@tidb06 14:01: [test01]> select * from tb2; +----+----------+------------+---------------------+ | id | username | password | create_time | +----+----------+------------+---------------------+ | 1 | tomcat | xiaohuahua | 2021-07-21 14:01:50 | | 2 | java | xiaohuahua | 2021-07-21 14:01:59 | +----+----------+------------+---------------------+ 2 rows in set (0.00 sec)
clickhouse库的建表创建方法:
CREATE TABLE tb2 ENGINE = MergeTree PARTITION BY toYYYYMM(create_time) ORDER BY create_time AS SELECT * FROM mysql('172.16.0.247:3306', 'test01', 'tb2', 'click_rep', 'jwts996');
提示:clichhouse表中要求必须至少包含一个时间字段
tidb05 :) CREATE TABLE tb2 ENGINE = MergeTree PARTITION BY toYYYYMM(create_time) ORDER BY create_time AS SELECT * FROM mysql('172.16.0.247:3306', 'test01', 'tb2', 'click_rep', 'jwts996'); CREATE TABLE tb2 ENGINE = MergeTree PARTITION BY toYYYYMM(create_time) ORDER BY create_time AS SELECT * FROM mysql('172.16.0.247:3306', 'test01', 'tb2', 'click_rep', 'jwts996') Ok. 0 rows in set. Elapsed: 0.014 sec. tidb05 :) select * from tb2; SELECT * FROM tb2 ┌─id─┬─username─┬─password───┬─────────create_time─┐ │ 1 │ tomcat │ xiaohuahua │ 2021-07-21 14:01:50 │ │ 2 │ java │ xiaohuahua │ 2021-07-21 14:01:59 │ └────┴──────────┴────────────┴─────────────────────┘ 2 rows in set. Elapsed: 0.002 sec.
关于“如何将MySQL的表数据全量导入clichhouse库中”这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对“如何将MySQL的表数据全量导入clichhouse库中”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。