1. 程式人生 > >mysql 檢視連線數,狀態,最大併發數

mysql 檢視連線數,狀態,最大併發數

show status like '%max_connections%'; ##mysql最大連線數
set global max_connections=1000 ##重新設定
show variables like '%max_connections%'; ##查詢資料庫當前設定的最大連線數

show global status like 'Max_used_connections'; ##伺服器響應的最大連線數

show status like 'Threads%';

Variable_name Value
Threads_cached 0 ##mysql管理的執行緒池中還有多少可以被複用的資源
Threads_connected 152 ##開啟的連線數
Threads_created 550 ##表示建立過的執行緒數,如果發現Threads_created值過大的話,表明MySQL伺服器一直在建立執行緒,這也是比較耗資源,可以適當增加配置檔案中thread_cache_size值,查詢伺服器
Threads_running 1 ##啟用的連線數,這個數值一般遠低於connected數值,準確的來說,Threads_running是代表當前併發數

show variables like 'thread_cache_size';
set global thread_cache_size=60;