Skip to content

Commit

Permalink
update alter user (#3036)
Browse files Browse the repository at this point in the history
* update alter user

* Update 2.management-user.md

* Update 2.management-user.md
  • Loading branch information
cooper-lzy authored Oct 11, 2023
1 parent acc41d7 commit 6801c14
Showing 1 changed file with 47 additions and 22 deletions.
69 changes: 47 additions & 22 deletions docs-2.0/7.data-security/1.authentication/2.management-user.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

执行`CREATE USER`语句可以创建新的{{nebula.name}}用户。当前仅** God **角色用户(即`root`用户)能够执行`CREATE USER`语句。


{{ comm.comm_begin }}
- 语法

```ngql
Expand All @@ -23,34 +23,40 @@
- `IF NOT EXISTS`:检测待创建的用户名是否存在,只有不存在时,才会创建新用户。
- `user_name`:待创建的用户名。长度最多为 16 个字符。
- `password`:用户名对应的密码。默认密码为空字符串(`''`)。长度最多为 24 个字符。
{{ comm.comm_end }}

{{ ent.ent_begin }}

- 企业版语法
- 语法

```ngql
CREATE USER [IF NOT EXISTS] <user_name> [WITH PASSWORD '<password>'][WITH IP WHITELIST <ip_list>];
```

- `ip_list`(企业版):IP 白名单列表。不使用该选项时任何 IP 都可以连接到数据库。使用该选项后,只有列表内的 IP 才能连接数据库。多个 IP 之间用英文逗号(,)分隔。
- `IF NOT EXISTS`:检测待创建的用户名是否存在,只有不存在时,才会创建新用户。
- `user_name`:待创建的用户名。长度最多为 16 个字符。
- `password`:用户名对应的密码。默认密码为空字符串(`''`)。长度最多为 24 个字符。
- `ip_list`:IP 白名单列表。该用户只有通过列表内的 IP 才能连接{{nebula.name}}。多个 IP 之间用英文逗号(,)分隔。

{{ ent.ent_end }}

{{ comm.comm_begin }}
- 示例

```ngql
nebula> CREATE USER user1 WITH PASSWORD 'nebula';
nebula> SHOW USERS;
+---------+-------------------------------+
| Account | IP Whitelist |
+---------+-------------------------------+
| "root" | "" |
| "user1" | "" |
+---------+-------------------------------+
+---------+
| Account |
+---------+
| "root" |
| "user1" |
+---------+
```
{{ comm.comm_end }}

{{ ent.ent_begin }}
- 企业版示例
- 示例

```ngql
nebula> CREATE USER user2 WITH PASSWORD 'nebula' WITH IP WHITELIST 192.168.10.10,192.168.10.12;
Expand Down Expand Up @@ -158,45 +164,64 @@

执行`ALTER USER`语句可以修改用户密码,修改时不需要提供旧密码。当前仅** God **角色用户(即`root`用户)能够执行`ALTER USER`语句。

{{ comm.comm_begin }}
- 语法

```ngql
ALTER USER <user_name> WITH PASSWORD '<password>';
```
{{ comm.comm_end }}

{{ ent.ent_begin }}
- 企业版语法
- 语法

```ngql
ALTER USER <user_name> WITH PASSWORD '<password>' [WITH IP WHITELIST <ip_list>];
ALTER USER <user_name> [WITH PASSWORD '<password>'] [WITH IP WHITELIST <ip_list>];
```
{{ ent.ent_end }}

{{ comm.comm_begin }}
- 示例

```ngql
nebula> ALTER USER user2 WITH PASSWORD 'nebula';
nebula> SHOW USERS;
+---------+--------------+
| Account | IP Whitelist |
+---------+--------------+
| "root" | "" |
| "user1" | "" |
| "user2" | "" |
+---------+--------------+
+---------+
| Account |
+---------+
| "root" |
| "user1" |
| "user2" |
+---------+
```
{{ comm.comm_end }}

{{ ent.ent_begin }}

- 企业版示例
- 示例

!!! enterpriseonly

没有使用`WITH IP WHITELIST`时,表示取消 IP 白名单,用户使用任何 IP 都可以连接{{nebula.name}}。
使用`WITH IP WHITELIST`时,后面不填写任何 IP 表示取消白名单,用户使用任何 IP 都可以连接{{nebula.name}}。

```ngql
nebula> ALTER USER user2 WITH PASSWORD 'nebula';
nebula> ALTER USER user2 WITH PASSWORD 'nebula' WITH IP WHITELIST 192.168.10.10;
nebula> SHOW USERS;
+---------+-----------------+
| Account | IP Whitelist |
+---------+-----------------+
| "root" | "" |
| "user2" | "192.168.10.10" |
+---------+-----------------+
nebula> ALTER USER user2 WITH IP WHITELIST;
nebula> SHOW USERS;
+---------+--------------+
| Account | IP Whitelist |
+---------+--------------+
| "root" | "" |
| "user2" | "" |
+---------+--------------+
```
{{ ent.ent_end }}

Expand Down

0 comments on commit 6801c14

Please sign in to comment.