@@ -36,6 +36,9 @@ StringName ::=
36
36
stringLit
37
37
| Identifier
38
38
39
+ ConnectionOptions ::=
40
+ ( 'WITH' 'MAX_USER_CONNECTIONS' N )?
41
+
39
42
PasswordOption ::= ( 'PASSWORD' 'EXPIRE' ( 'DEFAULT' | 'NEVER' | 'INTERVAL' N 'DAY' )?
40
43
| 'PASSWORD' 'HISTORY' ( 'DEFAULT' | N )
41
44
| 'PASSWORD' 'REUSE' 'INTERVAL' ( 'DEFAULT' | N 'DAY' )
@@ -168,18 +171,34 @@ CREATE USER 'newuser9'@'%' PASSWORD EXPIRE;
168
171
Query OK, 1 row affected (0.02 sec)
169
172
```
170
173
174
+ 创建一个限制最大连接数为 3 的用户。
175
+
176
+ ``` sql
177
+ CREATE USER 'newuser10 '@' %' WITH MAX_USER_CONNECTIONS 3 ;
178
+ SELECT User, Host, max_user_connections FROM mysql .user WHERE User= ' newuser10' ;
179
+ ```
180
+
181
+ ```
182
+ +-----------+------+----------------------+
183
+ | user | host | max_user_connections |
184
+ +-----------+------+----------------------+
185
+ | newuser10 | % | 3 |
186
+ +-----------+------+----------------------+
187
+ 1 row in set (0.01 sec)
188
+ ```
189
+
171
190
创建一个使用资源组 ` rg1 ` 的用户:
172
191
173
192
``` sql
174
- CREATE USER 'newuser7 '@' %' RESOURCE GROUP rg1;
175
- SELECT USER, HOST, USER_ATTRIBUTES FROM MYSQL .USER WHERE USER= ' newuser7 ' ;
193
+ CREATE USER 'newuser11 '@' %' RESOURCE GROUP rg1;
194
+ SELECT USER, HOST, USER_ATTRIBUTES FROM MYSQL .USER WHERE USER= ' newuser11 ' ;
176
195
```
177
196
178
197
``` sql
179
198
+ -- ---------+------+---------------------------------------------------+
180
199
| USER | HOST | USER_ATTRIBUTES |
181
200
+ -- ---------+------+---------------------------------------------------+
182
- | newuser7 | % | {" resource_group" : " rg1" } |
201
+ | newuser11 | % | {" resource_group" : " rg1" } |
183
202
+ -- ---------+------+---------------------------------------------------+
184
203
1 rows in set (0 .00 sec)
185
204
```
@@ -191,7 +210,6 @@ TiDB 不支持以下 `CREATE USER` 选项。这些选项可被解析,但会被
191
210
* ` PASSWORD REQUIRE CURRENT DEFAULT `
192
211
* ` WITH MAX_QUERIES_PER_HOUR `
193
212
* ` WITH MAX_UPDATES_PER_HOUR `
194
- * ` WITH MAX_USER_CONNECTIONS `
195
213
196
214
TiDB 也不支持以下 ` CREATE USER ` 选项。这些选项无法被语法解析器解析。
197
215
0 commit comments