Clickhouse grant add user error

问题

Clickhouse使用Grant给用户添加权限

GRANT SELECT, INSERT ON  
system.xxx
TO read_user01
on cluster xxx ;

遇到异常

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 为用户添加权限
<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>