通過mysql操作clickhouse
阿新 • • 發佈:2020-08-04
mysql軟體安裝
至少需要安裝一個mysql客戶端,即要有mysql這個命令;也可以直接安裝一個mysql資料庫,不用可以不啟動;
clickhouse服務端配置mysql埠
vim /etc/clickhouse-server/config.xml
<mysql_port>9004</mysql_port>
修改伺服器端配置,需要重啟clickhouse, 預設日誌輸出 /var/log/clickhouse-server/clickhouse-server.log
下面這種方式,需要在本地配置mysql,然後本地連線,預設省去的連線主機為localhost
[root@ch2 ~]# mysql --protocol tcp -u default-P 9004 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 0 Server version: 20.3.9.70-ClickHouse Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +----------+ | name | +----------+ | default | | system | | test | | tutorial | +----------+ 4 rows in set (0.01 sec) Read 4 rows, 475.00 B in 0.001 sec., 3554 rows/sec., 412.20 KiB/sec. mysql> use test; Reading table informationfor completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show tables; +------+ | name | +------+ | test | +------+ 1 row in set (0.01 sec) Read 1 rows, 26.00 B in 0.001 sec., 771 rows/sec., 19.60 KiB/sec.
同樣可以建立表
mysql> create table t1(id String,name String) ENGINE=TinyLog;
Query OK, 0 rows affected (0.01 sec)
mysql> insert into t1 values('a01','');
Query OK, 1 row affected (0.00 sec)
Read 1 rows, 21.00 B in 0.004 sec., 275 rows/sec., 5.64 KiB/sec.
mysql> select * from t1;
+------+------+
| id | name |
+------+------+
| a01 | |
+------+------+
1 row in set (0.01 sec)
Read 1 rows, 21.00 B in 0.002 sec., 525 rows/sec., 10.78 KiB/sec.