Mysql 查看鏈接數,狀態 最大併發數,以及設置鏈接數

 

show variables like '%max_connections%'; 查看最大鏈接數mysql

set global max_connections=1000  從新設置最大鏈接數sql

 

set-variable=max_user_connections=30                    這個就是單用戶的鏈接數
set-variable=max_connections=800                            這個是全局的限制鏈接數緩存

------------------------------------------------------------------------------------------------------------服務器

以root賬號登陸,查詢全部用戶的當前鏈接 spa

show full processlist;  線程

 

 

show status like 'Threads%';進程

+-------------------+-------+
| Threads_cached    | 58    |
| Threads_connected | 57    |   ###這個數值指的是打開的鏈接數
| Threads_created   | 3676  |
| Threads_running   | 4     |   ###這個數值指的是激活的鏈接數,這個數值通常遠低於connected數值ssl

+-------------------+-------+
 
MySQL服務器的線程數須要在一個合理的範圍以內,這樣才能保證MySQL服務器健康平穩地運行。Threads_created表示建立過的線程數,經過查看Threads_created就能夠查看MySQL服務器的進程狀態。
1. mysql> show global status like 'Thread%';
2. +-------------------+-------+
3. | Variable_name | Value |
4. +-------------------+-------+
5. | Threads_cached | 46 |
6. | Threads_connected | 2 |
7. | Threads_created | 570 |
8. | Threads_running | 1 |
9. +-------------------+-------+
若是咱們在MySQL服務器配置文件中設置了thread_cache_size,當客戶端斷開以後,服務器處理此客戶的線程將會緩存起來以響應下一個客戶而不是銷燬(前提是緩存數未達上限)。
Threads_created表示建立過的線程數,若是發現Threads_created值過大的話, 代表MySQL服務器一直在建立線程,這也是比較耗資源,能夠適當增長配置文件中thread_cache_size值,查詢服務器
thread_cache_size配置:
1. mysql> show variables like 'thread_cache_size';
2. +-------------------+-------+
3. | Variable_name | Value |
4. +-------------------+-------+
5. | thread_cache_size | 64 |
6. +-------------------+-------+
相關文章
相關標籤/搜索