Problem description : hold max_connections and max_user_connections Parameters for analysis and test , seeing the name of a thing one thinks of its function ,max_connections Is the number of connections that are responsible for the global database ,max_user_connections You can limit the maximum number of connections for a single user .
1. Temporary modification max_user_connections Global parameter , When max_user_connections by 0 when , There are no restrictions on all parameters under the database , However, it does not mean that the user under the database has not enabled this parameter
mysql> set global max_user_connections=1;
Query OK, 0 rows affected (0.00 sec)
Open multiple windows to test the connection , The connection fails
[[email protected] ~]# /usr/local/mysql8/bin/mysql -utest01 -p123 -h192.168.163.21 -P33306
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1203 (42000): User test01 already has more than 'max_user_connections' active connections
2. Restrict the connection of a single user
Restart to release the temporarily set parameters
mysql> restart
-> ;
Query OK, 0 rows affected (0.01 sec)
mysql> show variables like '%max_user_conn%';
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| max_user_connections | 0 |
+----------------------+-------+
1 row in set (0.01 sec)
Set connection limits for a single user , The statement given by the official document ,
mysql> CREATE USER 'francis'@'localhost' IDENTIFIED BY 'frank'
-> WITH MAX_QUERIES_PER_HOUR 20
-> MAX_UPDATES_PER_HOUR 10
-> MAX_CONNECTIONS_PER_HOUR 5
-> MAX_USER_CONNECTIONS 2;
Conduct user connection test , You will see the prompt that the maximum number of connections is 3 when , The connection fails
[[email protected] ~]# /usr/local/mysql8/bin/mysql -ufrancis -pfrank -S /data/mysql8/db_dxpt08/mysql.sock
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1226 (42000): User 'francis' has exceeded the 'max_user_connections' resource (current value: 3)
Users who successfully test view the current connection information , The maximum number of user connections that can be seen by connected users here is 2, however root Observed global max_user_connections still 0
mysql> show variables like '%max_user_connections%';
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| max_user_connections | 2 |
+----------------------+-------+
1 row in set (0.00 sec)
3. If you want to see where the modified parameters are set , Need user See these in the table
mysql> select * from user where user='francis'\G
*************************** 1. row ***************************
Host: localhost
User: francis
Select_priv: N
Insert_priv: N
Update_priv: N
Delete_priv: N
Create_priv: N
Drop_priv: N
Reload_priv: N
Shutdown_priv: N
Process_priv: N
File_priv: N
Grant_priv: N
References_priv: N
Index_priv: N
Alter_priv: N
Show_db_priv: N
Super_priv: N
Create_tmp_table_priv: N
Lock_tables_priv: N
Execute_priv: N
Repl_slave_priv: N
Repl_client_priv: N
Create_view_priv: N
Show_view_priv: N
Create_routine_priv: N
Alter_routine_priv: N
Create_user_priv: N
Event_priv: N
Trigger_priv: N
Create_tablespace_priv: N
ssl_type:
ssl_cipher: 0x
x509_issuer: 0x
x509_subject: 0x
max_questions: 20
max_updates: 10
max_connections: 5
max_user_connections: 2
plugin: mysql_native_password
authentication_string: *63DAA25989C7E01EB96570FA4DBE154711BEB361
password_expired: N
password_last_changed: 2022-06-13 10:46:16
password_lifetime: NULL
account_locked: N
Create_role_priv: N
Drop_role_priv: N
Password_reuse_history: NULL
Password_reuse_time: NULL
Password_require_current: NULL
User_attributes: NULL
1 row in set (0.01 sec)
4. Two official amendments are attached max_user_connections The way
mysql> CREATE USER 'francis'@'localhost' IDENTIFIED BY 'frank'
-> WITH MAX_QUERIES_PER_HOUR 20
-> MAX_UPDATES_PER_HOUR 10
-> MAX_CONNECTIONS_PER_HOUR 5
-> MAX_USER_CONNECTIONS 2; mysql> ALTER USER 'francis'@'localhost' WITH MAX_QUERIES_PER_HOUR 100;
mysql> ALTER USER 'francis'@'localhost' WITH MAX_QUERIES_PER_HOUR 100;
5. Conclusion
1.max_connections You can manage the global maximum number of connections .
2.max_user_connections Responsible for limiting the maximum number of connections per user , The number of settings cannot exceed max_connections.max_user_connections When opening global variables , Will affect all users , Except that... Is set separately max_user_connections All users of the parameter .
mysql in max_connections And max_user_connections More related articles on using differences
- mysql Of max_connections and max_user_connections The difference between
---- see max_user_connections The default value is MySQL> show variables like 'max_user_connections'; +-------------- ...
- use count(*) still count( Name ) || Mysql Medium count() And sum() difference
Mysql Medium count() And sum() difference First, create a table to illustrate the problem CREATE TABLE `result` ( `name` varchar(20) default NULL, `su ...
- ( turn )MySQL in In And Exists The difference between
background : summary mysql Related knowledge . If A Table has n Bar record , that exists Query is to put this n Take out the records one by one , And then determine n All over exists Conditions . select * from user where exists s ...
- MySQL in interactive_timeout and wait_timeout The difference between 【 turn 】
In use mysql When the client operates the database , Open terminal window , If there is no operation for a period of time , When operating again , The following mistakes are often reported : ERROR 2013 (HY000): Lost connection to MySQL s ...
- Mysql The difference between functions and stored procedures in
Mysql The difference between functions and stored procedures in stored procedure : 1. Can write sql sentence 2. inout,out Construct the return value 3. call :call: Stored procedure name 4. Sure ...
- mysql in in and exist The difference between
mysql in in and exists The difference between -- in How to write it select * from A where A.id in (select bid from B ) and A.name in (select ...
- MySQL in utf8 And utf8mb4 The difference between
MySQL in utf8 And utf8mb4 The difference between One . brief introduction MySQL stay 5.5.3 Then I added this utf8mb4 The coding ,mb4 Namely most bytes 4 It means , Designed to be compatible with four bytes unicode. Fortunately ...
- MySQL in NULL The difference between null value and null value
Usually we use MySQL When , about MySQL Medium NULL The difference between a value and a null value is not well understood . be aware NULL The value is unknown , And take up space , Don't walk index ,DBA It is recommended to set the fields when creating tables NOT NULL To avoid this inefficiency ...
- mysql in char And varchar Difference analysis of ( Add a sentence ,int and integer No difference )
from :http://www.jb51.net/article/23575.htm stay mysql tutorial char And varchar What's the difference? , Are used to store strings , It's just that they keep it in a different way ,char It's fixed ...
- MySQL in NULL The difference between null value and null value ( Reprint http://blog.sina.com.cn/s/blog_3f2a82610102v4dn.html)
Usually we use MySQL When , about MySQL Medium NULL The difference between a value and a null value is not well understood . be aware NULL The value is unknown , And take up space , Don't walk index ,DBA It is recommended to set the fields when creating tables NOT NULL To avoid this inefficiency ...
Random recommendation
- BZOJ 1862: [Zjoi2006]GameZ Game ranking system [treap hash]
1862: [Zjoi2006]GameZ Game ranking system Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 1318 Solved: 498[Submit][ ...
- POJ 2785 4 Values whose Sum is 0
4 Values whose Sum is 0 Time Limit: 15000MS Memory Limit: 228000K Total Submissions: 13069 Accep ...
- activiti Custom process Spring Integrate activiti-modeler5.16 example ( Nine ): Historical task query
notes :(1) Environment building :activiti Custom process Spring Integrate activiti-modeler5.16 example ( One ): Environment building (2) Create a process model :activiti Custom process Spring ...
- jquery-ui-widget
To write jQueryUI plug-in unit (widget) Use jQueryUI Of widget To write plug-ins , Compared to the basic jquery Plug ins have some benefits : * Easy to implement inheritance , code reuse * The default is single instance * widget It has been realized for you ...
- Dig a hole , Write a Spring+SpringMVC+Mybatis Project
I want to dig a hole and urge myself to practice , Sometimes I think of a project , I think about some functions to be realized , How to achieve . Now I feel like I can almost finish QQ The main function of space . Prepare to build a memorial archway , Write a website with similar functions . And put the schedule here . Preliminary plan to achieve ...
- If TransactionScope will close database connections
ask Do TransactionScope work with closed database connections? using (var transaction = new Transactio ...
- Win7 64bit install VisualSVN There is an error :Servic 'VisualSVN Server' failed to start. solution
Problem description and narration : Win7 64bit install VisualSVN An error was reported : Servic 'VisualSVN Server' failed to start.Please check VisualSV ...
- CVPixelBuffer
https://www.cnblogs.com/psklf/p/7700834.html https://stackoverflow.com/questions/16475737/convert-ui ...
- IDEA Related settings
I finally gave up today MyEclipse, In the use of MyEclipse I don't want to say much about all kinds of heartaches in my life , In a word : Cherish life, , Stay away from MyEclipse. Switch to IDEA after , Installed IdeaVim plug-in unit , Support vim The operation of , Improved ...
- 【 turn 】java Format output printf Example
[ turn ]java Format output printf Example from http://www.cnblogs.com/TankMa/archive/2011/08/20/2146913.html#undefined imp ...