mysql clickhouse_通过mysql操作clickhouse

mysql软件安装

至少需要安装一个mysql客户端,即要有mysql这个命令;也可以直接安装一个mysql数据库,不用可以不启动;

clickhouse服务端配置mysql端口

vim /etc/clickhouse-server/config.xml

9004

修改服务器端配置,需要重启clickhouse, 默认日志输出 /var/log/clickhouse-server/clickhouse-server.log

下面这种方式,需要在本地配置mysql,然后本地连接,默认省去的连接主机为localhost

[root@ch2 ~]# mysql --protocol tcp -u default -P 9004Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection idis 0Server version:20.3.9.70-ClickHouse

Copyright (c)2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracleis 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.01sec)

Read4 rows, 475.00 B in 0.001 sec., 3554 rows/sec., 412.20 KiB/sec.

mysql>use test;

Reading table informationforcompletion of table and column names

You can turn offthis feature to get a quicker startup with -A

Database changed

mysql>show tables;+------+

| name |

+------+

| test |

+------+

1 row in set (0.01sec)

Read1 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.

密码配置

为了兼容mysql客户端,建议clickhouse使用sha1加密算法

生成密码,这个生成命令在 /etc/clickhouse-server/users.xml 注释部分,是官方给出的

# PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD"\> | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-'yOBuWUzN

1caa12e10ba19388e98b0964eb25e93128fd0ace

删除下面的标签

添加新标签

1caa12e10ba19388e98b0964eb25e93128fd0ace

再次连接,不需要重启clickhouse

mysql --protocol tcp -u default -P 9004 --password=yOBuWUzN

去掉密码也可以连接

mysql --protocol tcp -u default -P 9004

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值