Clickhouse grant add user error

Ordiy Lv5

问题

Clickhouse使用Grant给用户添加权限

1
2
3
4
GRANT SELECT, INSERT ON  
system.xxx
TO read_user01
on cluster xxx ;

遇到异常

1
2
3
Code: 495. DB::Exception: Received from localhost:9000. DB::Exception: There was an error on [xx-host.com:9000]: Code: 495. DB::Exception: Cannot update user `read_user01` in users_xml because this storage is readonly. (ACCESS_STORAGE_READONLY) (version 24.10.2.80 (official build)). (ACCESS_STORAGE_READONLY)


原因

read_user01 是在 /etc/clickhouse-server/user.d/user.xml中配置的,无法使用grant给该用户添加权限。

  • 解决 在Clickhouse集群上,手动修改 /etc/clickhouse-server/user.d/user.xml 为用户添加权限
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<clickhouse>
<users>

<read_user01>
<profile>readonly-user-max-quato</profile>
<password_sha256_hex>xxxx</password_sha256_hex>
<quota>default</quota>
<allow_databases>
<database>xxxx</database>
</allow_databases>
</read_user01>

</users>
</clickhouse>
  • Title: Clickhouse grant add user error
  • Author: Ordiy
  • Created at : 2025-03-31 14:42:19
  • Updated at : 2025-04-17 10:06:43
  • Link: https://ordiy.github.io/posts/2025-03-01-clickhouse-user-access-storage-readonly/
  • License: This work is licensed under CC BY 4.0.
On this page
Clickhouse grant add user error