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: pkg/errno/errname.go
+1-1
Original file line number
Diff line number
Diff line change
@@ -217,7 +217,7 @@ var MySQLErrName = map[uint16]*mysql.ErrMessage{
217
217
ErrCrashedOnRepair: mysql.Message("Table '%-.192s' is marked as crashed and last (automatic?) repair failed", nil),
218
218
ErrWarningNotCompleteRollback: mysql.Message("Some non-transactional changed tables couldn't be rolled back", nil),
219
219
ErrTransCacheFull: mysql.Message("Multi-statement transaction required more than 'maxBinlogCacheSize' bytes of storage; increase this mysqld variable and try again", nil),
220
-
ErrTooManyUserConnections: mysql.Message("User %-.64s already has more than 'maxUserConnections' active connections", nil),
220
+
ErrTooManyUserConnections: mysql.Message("User %-.64s has exceeded the 'max_user_connections' resource", nil),
221
221
ErrSetConstantsOnly: mysql.Message("You may only use constant expressions with SET", nil),
tk.MustExec(`set global max_user_connections = 3;`)
241
+
tk.MustQuery(`show variables like 'max_user_connections'`).Check(testkit.Rows("max_user_connections 3"))
242
+
// if the value < 0, set 0 to max_user_connections.
243
+
tk.MustExec(`set global max_user_connections = -1;`)
244
+
tk.MustQuery(`show variables like 'max_user_connections'`).Check(testkit.Rows("max_user_connections 0"))
245
+
// if the value > 100000, set 100000 to max_user_connections.
246
+
tk.MustExec(`set global max_user_connections = 100001;`)
247
+
tk.MustQuery(`show variables like 'max_user_connections'`).Check(testkit.Rows("max_user_connections 100000"))
248
+
tk.MustExec(`set global max_user_connections = 0;`)
249
+
tk.MustQuery(`show variables like 'max_user_connections'`).Check(testkit.Rows("max_user_connections 0"))
250
+
251
+
// create user with the default max_user_connections 0
252
+
createUserSQL:=`CREATE USER 'test'@'localhost';`
253
+
tk.MustExec(createUserSQL)
254
+
result=tk.MustQuery(`select user, max_user_connections from mysql.user`)
255
+
result.Check(testkit.Rows("root 0", "test 0"))
256
+
257
+
// create user with max_user_connections 3
258
+
createUserSQL=`CREATE USER 'test1'@'localhost' WITH MAX_USER_CONNECTIONS 3;`
259
+
tk.MustExec(createUserSQL)
260
+
result=tk.MustQuery(`select user, max_user_connections from mysql.user WHERE User="test1"`)
261
+
result.Check(testkit.Rows("test1 3"))
262
+
263
+
// test alter user with MAX_USER_CONNECTIONS
264
+
alterUserSQL:=`ALTER USER 'test1'@'localhost' WITH MAX_USER_CONNECTIONS 4;`
265
+
tk.MustExec(alterUserSQL)
266
+
result=tk.MustQuery(`select user, max_user_connections from mysql.user WHERE User="test1"`)
267
+
result.Check(testkit.Rows("test1 4"))
268
+
alterUserSQL=`ALTER USER 'test1'@'localhost' WITH MAX_USER_CONNECTIONS -2;`
269
+
_, err:=tk.Exec(alterUserSQL)
270
+
require.Error(t, err)
271
+
require.Equal(t, err.Error(), "[parser:1064]You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 58 near \"-2;\" ")
272
+
alterUserSQL=`ALTER USER 'test1'@'localhost' WITH MAX_USER_CONNECTIONS 0;`
273
+
tk.MustExec(alterUserSQL)
274
+
result=tk.MustQuery(`select user, max_user_connections from mysql.user WHERE User="test1"`)
275
+
result.Check(testkit.Rows("test1 0"))
276
+
277
+
// grant the privilege of 'create user' to 'test1'@'localhost'
0 commit comments