ClickHouse 这点不错,支持MySQL wire通讯协议,用 mysql 命令行直接连 ClickHouse 服务器,用起来跟 MySQL 几乎一样。
mysql 命令行客户端版本:8.0.16
ClickHouse 服务器版本:24.1.8.22
不需要任何配置,只要网通,用 mysql 使用缺省的 9004 端口连接 ClickHouse 实例的 IP 即可:
代码语言:javascript复制[mysql@vvgg-z2-music-mysqld~]$mysql --protocol tcp -u default -p123456 -P 9004 -h 172.18.4.126 -e "status;select version();show databases;select count(*) from db1.hits_replica_all;" -vv 2>/dev/null
--------------
mysql Ver 8.0.16 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)
Connection id: 24
Current database: default
Current user: default
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 24.1.8.22-ClickHouse
Protocol version: 10
Connection: 172.18.4.126 via TCP/IP
Server characterset: 0
Db characterset: 0
Client characterset: 0
Conn. characterset: 0
TCP port: 9004
--------------
--------------
select version()
--------------
-----------
| version() |
-----------
| 24.1.8.22 |
-----------
1 row in set (0.01 sec)
Read 1 rows, 1.00 B in 0.000272 sec., 3676 rows/sec., 3.59 KiB/sec.
--------------
show databases
--------------
--------------------
| name |
--------------------
| INFORMATION_SCHEMA |
| db1 |
| default |
| information_schema |
| system |
| tutorial |
--------------------
6 rows in set (0.00 sec)
Read 6 rows, 114.00 B in 0.000443 sec., 13544 rows/sec., 251.31 KiB/sec.
--------------
select count(*) from db1.hits_replica_all
--------------
---------
| count() |
---------
| 8873898 |
---------
1 row in set (0.00 sec)
Read 2 rows, 32.00 B in 0.004355 sec., 459 rows/sec., 7.18 KiB/sec.
Bye
[mysql@vvgg-z2-music-mysqld~]$