解析mysql中max_connections與max_user_connections的區別_Mysql
來源:互聯網
上載者:User
在mysql的手冊中已經對max_user_connections有一點說明,它是用來限制使用者資源的,怎麼限制使用者資源呢?這裡做了個小測試。
首先產看該全域變數的值
mysql> select @@max_user_connections;
+------------------------+
| @@max_user_connections |
+------------------------+
| 0 |
+------------------------+
1 row in set (0.00 sec)
預設情況系是為0的
為0是什麼意思呢?它是說不限制使用者資源的。
在這裡我改變一下它的值,並在查詢,注意這改變在伺服器重啟後無效,想一直儲存的話就放在選項檔案裡面!
mysql> set @@global.max_user_connections=1;
Query OK, 0 rows affected (0.00 sec)
mysql> select @@max_user_connections;
+------------------------+
| @@max_user_connections |
+------------------------+
| 1 |
+------------------------+
1 row in set (0.00 sec)
現在我重新開啟一個串連
C:\Windows\System32>mysql -uroot -pweb
ERROR 1203 (42000): User root already has more than 'max_user_connections' activ
e connections
意思是這個使用者已經達到最大的串連數,不能再串連擁有資源!
該參數只能對整體限制資源,不能對某個使用者進行限制,如果需要對某個使用者限制的話,你可以在許可權表裡面看到
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
這幾個參數可以對某個使用者進行限制。
max_connections 的意思是對整個伺服器的使用者限制!