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 *.*.
If you just started using ClickHouse, consider the following scenario: Enable SQL-driven access control and account management for the default user. Log in to the default user account and create all the required users. Don't forget to create an administrator account ( GRANT ALL ON *.
Account creation By default ClickHouse creates a user with the name Default without a password. You can set up a password in an open or encoded way (SHA-256).
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> -->
..
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With