• 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
  • 相关阅读:
    异常:no transaction is in progress
    软件杯 深度学习YOLO安检管制物品识别与检测 - python opencv
    [ACNOI2022]总差一步
    APP安全加固怎么做?加固技术、加固方法、加固方案
    Windows下Apache2.4配置SSL(HTTPS)
    Win11+VS2022配置编译VTK9.1
    利用grafana&prometheus 快速配置 k8s & 主机监控
    TAMRA-NHS 荧光素-活性酯
    【BOOST C++容器专题03】【02】Boost.Bimap
    RabbitMQ基础篇 笔记
  • 原文地址:https://blog.csdn.net/Guzarish/article/details/126809548