首页 > 解决方案 > 如何为 Clickhouse 设置管理员帐户?

问题描述

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

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

解决方案


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

#  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

取消注释用户的access_management-settingdefault并保存更改:

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

推荐阅读