13

I'm running Clickhouse in a docker container on a Windows host. I tried to create an account towards making it an admin account. It looks like the default user does not have permission to create other accounts. How can I get around this error and create an admin account?

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

gave the error

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 *.*.
frosty
  • 2,421
  • 6
  • 26
  • 47

2 Answers2

13

To fix it need to enable access_management-setting in the users.xml file:

#  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

Uncomment the access_management-setting for the default user and save changes:

..
<!-- User can create other users and grant rights to them. -->
<!-- <access_management>1</access_management> -->
..
vladimir
  • 13,428
  • 2
  • 44
  • 70
  • Thanks, this worked!! It will be nice to have it set by .env file. Few steps below that I added to create admin user on my dev machine: CREATE USER 'foo' IDENTIFIED WITH plaintext_password BY 'bar' SET allow_introspection_functions=1 GRANT ALL ON *.* TO 'foo' WITH GRANT OPTION – frosty Oct 02 '20 at 16:31
5
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
Denny Crane
  • 11,574
  • 2
  • 19
  • 30