1. 程式人生 > 其它 >mysql檢視當前實時連線數

mysql檢視當前實時連線數

靜態檢視:

    SHOW PROCESSLIST;  
    SHOW FULL PROCESSLIST;  
    SHOW VARIABLES LIKE '%max_connections%';  
    SHOW STATUS LIKE '%Connection%';  

實時檢視:

    mysql> show status like 'Threads%';  
    +-------------------+-------+  
    | Variable_name     | Value |  
    +-------------------+-------+  
    | Threads_cached    | 58    |  
    | Threads_connected | 57    |   ###這個數值指的是開啟的連線數  
    | Threads_created   | 3676  |  
    | Threads_running   | 4     |   ###這個數值指的是啟用的連線數,這個數值一般遠低於connected數值  
    +-------------------+-------+  
       
    Threads_connected 跟show processlist結果相同,表示當前連線數。準確的來說,Threads_running是代表當前併發數  
       
    這是是查詢資料庫當前設定的最大連線數  
    mysql> show variables like '%max_connections%';  
    +-----------------+-------+  
    | Variable_name   | Value |  
    +-----------------+-------+  
    | max_connections | 100  |  
    +-----------------+-------+  
       
    可以在/etc/my.cnf裡面設定資料庫的最大連線數  
    max_connections = 1000  

----------------------------------
轉自 https://www.cnblogs.com/jimmyshan-study/p/11013662.html

本文來自部落格園,作者:up~up,轉載請註明原文連結:https://www.cnblogs.com/soft-engineer/p/15043928.html