华为clickhouse用户笔记
<h1>新版CK创建用户注意事项</h1>
<p>ck新版本比老版本的权限要高,所以在老版本的操作可能在新版本里面是失效的。
<strong>新版本必须先从manager创建用户,在到节点给用户授权。如果直接在节点创建用户和策略,会被自动清理掉,在节点创建角色权限不会被清理掉</strong></p>
<h1>例子:创建只读用户</h1>
<h2>1、进入其中一个节点,进入数据库</h2>
<pre><code>source /opt/Bigdata/FusionInsight_ClickHouse_*/*_ClickHouseServer/etc/ENV_VARS
$CLICKHOUSE_HOME/bin/clickhouse client --config-file $CLICKHOUSE_CONF_DIR/config.xml --host 192.168.0.15 --user clickhouse -m </code></pre>
<h2>2、查看用户、查看角色</h2>
<pre><code>select * from system.users;
select * from system.roles;</code></pre>
<h2>3、查看角色的权限</h2>
<pre><code>select * from system.grants where role_name='角色名称';</code></pre>
<h2>4、给角色授权权限</h2>
<pre><code>grant on cluster default_cluster select on *.* to ck_readonly_1695041205031 ;</code></pre>
<h2>5、查看角色的权限</h2>
<pre><code>select * from system.grants where role_name='角色名称';</code></pre>
<p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=dd4d85883192d84a115a5318e272befe&amp;file=file.png" alt="" /></p>