【问题标题】:How to setup an admin account for Clickhouse?如何为 Clickhouse 设置管理员帐户?
【发布时间】:2021-01-17 19:58:37
【问题描述】:

我正在 Windows 主机上的 docker 容器中运行 Clickhouse。我试图创建一个帐户以使其成为管理员帐户。 default 用户似乎没有创建其他帐户的权限。如何解决此错误并创建管理员帐户?

docker-compose exec -T dash-clickhouse clickhouse-client --query="CREATE USER 'foo' IDENTIFIED WITH sha256_password BY 'bar'"

报错

Received exception from server (version 20.7.2):
Code: 497. DB::Exception: Received from localhost:9000. DB::Exception: default: Not enough privileges. To execute this query it's necessary to have the grant CREATE USER ON *.*.

【问题讨论】:

    标签: clickhouse


    【解决方案1】:

    要修复它需要在users.xml 文件中启用access_management-setting:

    #  execute an interactive bash shell on the container
    docker-compose exec {container_name} bash
    # docker exec -it {container_name} bash
    
    # install preferable text editor (i prefer using 'nano')
    apt-get update
    apt-get install nano
    
    # open file users.xml in the editor
    nano /etc/clickhouse-server/users.xml
    

    取消注释default 用户的access_management 设置并保存更改:

    ..
    <!-- User can create other users and grant rights to them. -->
    <!-- <access_management>1</access_management> -->
    ..
    

    【讨论】:

    • 谢谢,这工作!用 .env 文件设置它会很好。在我的开发机器上创建管理员用户时添加了以下几个步骤: CREATE USER 'foo' IDENTIFIED WITH plaintext_password BY 'bar' SET allow_introspection_functions=1 GRANT ALL ON . TO 'foo' WITH GRANT OPTION
    【解决方案2】:
    mkdir -p  ~/Documents/docker/click/etc/conf.d
    
    cat ~/Documents/docker/click/etc/conf.d/zxylalalhuayk.xml
    <?xml version="1.0" ?>
    <yandex>
        <users>
            <default>
         <access_management>1</access_management>
            </default>
        </users>
    </yandex>
    
    
    docker run -d --name test  -v ~/Documents/docker/click/etc/conf.d/:/etc/clickhouse-server/conf.d --ulimit nofile=262144:262144  -p 8123:8123 yandex/clickhouse-server
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多