You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/sql-reference/10-sql-commands/00-ddl/02-user/01-user-create-user.md
+36-1
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ sidebar_position: 1
4
4
---
5
5
import FunctionDescription from '@site/src/components/FunctionDescription';
6
6
7
-
<FunctionDescriptiondescription="Introduced or updated: v1.2.424"/>
7
+
<FunctionDescriptiondescription="Introduced or updated: v1.2.566"/>
8
8
9
9
Creates a SQL user.
10
10
@@ -18,13 +18,15 @@ See also:
18
18
19
19
```sql
20
20
CREATE [ OR REPLACE ] USER <name> IDENTIFIED [ WITH <auth_type> ] BY '<password>'
21
+
[ WITH MUST_CHANGE_PASSWORD = true | false ]
21
22
[ WITH SET PASSWORD POLICY ='<policy_name>' ] -- Set password policy
22
23
[ WITH SET NETWORK POLICY ='<policy_name>' ] -- Set network policy
23
24
[ WITH DEFAULT_ROLE ='<role_name>' ] -- Set default role
24
25
[ WITH DISABLED = true | false ] -- User created in a disabled state
25
26
```
26
27
27
28
-*auth_type* can be `double_sha1_password` (default), `sha256_password` or `no_password`.
29
+
- When `MUST_CHANGE_PASSWORD` is set to `true`, the new user must change password at first login. Users can change their own password using the [ALTER USER](03-user-alter-user.md) command.
28
30
- When you set a default role for a user using CREATE USER or [ALTER USER](03-user-alter-user.md), Databend does not verify the role's existence or automatically grant the role to the user. You must explicitly grant the role to the user for the role to take effect.
29
31
- When `DISABLED` is set to `true`, the new user is created in a disabled state. Users in this state cannot log in to Databend until they are enabled. To enable or disable a created user, use the [ALTER USER](03-user-alter-user.md) command.
30
32
@@ -153,4 +155,37 @@ ALTER USER u1 WITH DISABLED = FALSE;
153
155
Welcome to BendSQL 0.16.0-homebrew.
154
156
Connecting to localhost:8000 as user u1.
155
157
Connected to Databend Query v1.2.424-nightly-d3a89f708d(rust-1.77.0-nightly-2024-04-17T22:11:59.304509266Z)
158
+
```
159
+
160
+
### Example 6: Creating User with MUST_CHANGE_PASSWORD
161
+
162
+
In this example, we will create a user with the `MUST_CHANGE_PASSWORD` option. Then, we will connect to Databend with BendSQL as the new user and change the password.
163
+
164
+
1. Create a new user named 'eric' with the `MUST_CHANGE_PASSWORD` option set to `TRUE`.
165
+
166
+
```sql
167
+
CREATEUSEReric IDENTIFIED BY 'abc123' WITH MUST_CHANGE_PASSWORD = TRUE;
168
+
```
169
+
170
+
2. Launch BendSQL and connect to Databend as the new user. Once connected, you'll see a message indicating that a password change is required.
171
+
172
+
```bash
173
+
MacBook-Air:~ eric$ bendsql -ueric -pabc123
174
+
```
175
+
176
+
3. Change the password with the [ALTER USER](03-user-alter-user.md) command.
177
+
178
+
```bash
179
+
eric@localhost:8000/default> ALTER USER USER() IDENTIFIED BY 'abc456';
180
+
```
181
+
182
+
4. Quit BendSQL then reconnect with the new password.
183
+
184
+
```bash
185
+
MacBook-Air:~ eric$ bendsql -ueric -pabc456
186
+
Welcome to BendSQL 0.19.2-1e338e1(2024-07-17T09:02:28.323121000Z).
187
+
Connecting to localhost:8000 as user eric.
188
+
Connected to Databend Query v1.2.567-nightly-78d41aedc7(rust-1.78.0-nightly-2024-07-14T22:10:13.777450105Z)
Copy file name to clipboardExpand all lines: docs/en/sql-reference/10-sql-commands/00-ddl/02-user/03-user-alter-user.md
+9-2
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ sidebar_position: 2
4
4
---
5
5
import FunctionDescription from '@site/src/components/FunctionDescription';
6
6
7
-
<FunctionDescriptiondescription="Introduced or updated: v1.2.424"/>
7
+
<FunctionDescriptiondescription="Introduced or updated: v1.2.566"/>
8
8
9
9
Modifies a user account, including:
10
10
@@ -17,7 +17,13 @@ Modifies a user account, including:
17
17
18
18
```sql
19
19
-- Modify password / authentication type
20
-
ALTERUSER<name> IDENTIFIED [ WITH auth_type ] BY '<password>'
20
+
ALTERUSER<name> IDENTIFIED [ WITH auth_type ] BY '<new_password>' [ WITH MUST_CHANGE_PASSWORD = true | false ]
21
+
22
+
-- Require user to modify password at next login
23
+
ALTERUSER<name> WITH MUST_CHANGE_PASSWORD = true
24
+
25
+
-- Modify password for currently logged-in user
26
+
ALTERUSER USER() IDENTIFIED BY '<new_password>'
21
27
22
28
-- Set password policy
23
29
ALTERUSER<name> WITH SET PASSWORD POLICY ='<policy_name>'
@@ -39,6 +45,7 @@ ALTER USER <name> WITH DISABLED = true | false
39
45
```
40
46
41
47
-*auth_type* can be `double_sha1_password` (default), `sha256_password` or `no_password`.
48
+
- When `MUST_CHANGE_PASSWORD` is set to `true`, the user must change their password at the next login. Please note that this takes effect only for users who have never changed their password since their account was created. If a user has ever changed their password themselves, then they do not need to change it again.
42
49
- When you set a default role for a user using [CREATE USER](01-user-create-user.md) or ALTER USER, Databend does not verify the role's existence or automatically grant the role to the user. You must explicitly grant the role to the user for the role to take effect.
43
50
-`DISABLED` allows you to enable or disable a user. Disabled users cannot log in to Databend until they are enabled. Click [here](01-user-create-user.md#example-5-creating-user-in-disabled-state) to see an example.
0 commit comments