您好,登錄后才能下訂單哦!
這篇文章主要介紹了如何將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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。