linux clickhouse 密码设置

默认密码

clickhouse 安装好之后,系统默认的登录账号密码是 /etc/clickhouse-server/users.d/default-password.xml 文件中配置的,默认密码是 SHA256加密算法生成,由 password_sha256_hex 标签定义,所以不输入密码时会发生如下报错:

复制代码
ClickHouse client version 22.8.4.7 (official build).
Connecting to localhost:9000 as user default.

If you have installed ClickHouse and forgot password you can reset it in the configuration file.
The password for default user is typically located at /etc/clickhouse-server/users.d/default-password.xml
and deleting this file will reset the password.
See also /etc/clickhouse-server/users.xml on the server where ClickHouse is installed.

Code: 516. DB::Exception: Received from localhost:9000. DB::Exception: default: Authentication failed: password is incorrect or there is no user with such name. (AUTHENTICATION_FAILED)

这时候我们只需要把 /etc/clickhouse-server/users.d/default-password.xml 文件删除掉或者重命名,之后只在 /etc/clickhouse-server/user.xml 文件中修改用户配置。

复制代码
cd /etc/clickhouse-server/users.d/

# 将默认用户配置文件重命名
mv default-password.xml default-pwd.xml

这时候不需要重启 clickhouse 就可以登录啦

复制代码
root@instance-0qymp8uo:/etc/clickhouse-server/users.d# clickhouse-client 
ClickHouse client version 22.8.4.7 (official build).
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 22.8.4 revision 54460.

instance-0qymp8uo :) 

clickhouse 密码设置

clickhouse 用户配置文件为 /etc/clickhouse-server/users.xml

clickhouse 密码有三种设置方式:明文、SHA256 和 SHA1 三种方式。

明文
明文密码则直接将要设置的密码放在标签:

复制代码
 <password></password>

password 标签为空时,代表免密码登录。

SHA256

通过下面命令生成密码,-c 表示要生成的长度;

复制代码
PASSWORD=$(base64 < /dev/urandom | head -c14); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-'

生成的第一行为明文密码,用于自己使用;第二行为 sha256 加密字符串,需要配置到下面标签中:

复制代码
<password_double_sha1_hex></password_double_sha1_hex>

double_shal

复制代码
PASSWORD=$(base64 < /dev/urandom | head -c16); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-'

生成的第一行为明文密码,用于自己使用;第二行为 double_shal 加密字符串,需要配置到下面标签中:

复制代码
<password_double_sha1_hex></password_double_sha1_hex>

最后不需要重启 clickhouse 就可以登录啦

如果加载失败,可以尝试重启一下

复制代码
sudo service clickhouse-server restart
posted @   牛奔  阅读(2093)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
历史上的今天:
2019-09-11 git 解决每次更新代码都要输入用户名密码
2019-09-11 navicat and connection is being used
2019-09-11 MySQL必知必会
点击右上角即可分享
微信分享提示