• linux clickhouse 密码设置


    默认密码

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

    1. ClickHouse client version 22.8.4.7 (official build).
    2. Connecting to localhost:9000 as user default.
    3. If you have installed ClickHouse and forgot password you can reset it in the configuration file.
    4. The password for default user is typically located at /etc/clickhouse-server/users.d/default-password.xml
    5. and deleting this file will reset the password.
    6. See also /etc/clickhouse-server/users.xml on the server where ClickHouse is installed.
    7. 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 文件中修改用户配置。

    1. cd /etc/clickhouse-server/users.d/
    2. # 将默认用户配置文件重命名
    3. mv default-password.xml default-pwd.xml

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

    1. root@instance-0qymp8uo:/etc/clickhouse-server/users.d# clickhouse-client
    2. ClickHouse client version 22.8.4.7 (official build).
    3. Connecting to localhost:9000 as user default.
    4. Connected to ClickHouse server version 22.8.4 revision 54460.
    5. 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
  • 相关阅读:
    关于seata启动时连接数据库异常,Mysql版本8.0
    女朋友说:你要搞懂了MySQL三大日志,我就让你嘿嘿嘿!
    后端大厂面试-15道题
    2.3队列
    18Java封装/private与public关键字
    Vue3实战笔记(57)—一键换肤:在Vuetify中打造个性化主题切换体验
    小程序门店自提功能,提高线上线下销售量
    299. 猜数字游戏
    Jmeter压测监控体系搭建Docker+Influxdb+Grafana
    蓝桥杯(数论)练习
  • 原文地址:https://blog.csdn.net/Guzarish/article/details/126809548