Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup an admin account for Clickhouse?

Tags:

clickhouse

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 *.*.
like image 803
frosty Avatar asked Oct 02 '20 05:10

frosty


People also ask

How do I add an admin user to ClickHouse?

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 *.

What is default ClickHouse user?

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).


2 Answers

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> -->
..
like image 97
vladimir Avatar answered Sep 21 '22 16:09

vladimir


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
like image 42
Denny Crane Avatar answered Sep 19 '22 16:09

Denny Crane