Check The Number Of MySQL Open Database Connections on Linux Or Unix-like Server Print

  • 0

MySQL show status command to see open database connections example

First, connect to the your mysql server:

mysql -u root -p

Type the following sql query to see the number of connection attempts to the MySQL server includes both failed and successful connection attempts:

mysql> show status like 'Conn%';
 You can use the following sql command to see the number of currently open connections at mysql> prompt:

 

mysql> show status like '%onn%';
+--------------------------+---------+
| Variable_name            | Value   |
+--------------------------+---------+
| Aborted_connects         | 7       |
| Connections              | 6304067 |
| Max_used_connections     | 85      |
| Ssl_client_connects      | 0       |
| Ssl_connect_renegotiates | 0       |
| Ssl_finished_connects    | 0       |
| Threads_connected        | 7       | <---- No of currently open connections 
+--------------------------+---------+
7 rows in set (0.00 sec)

Use show processlist sql command to see the number of open connections

Type the following sql command at mysql> prompt to see the number of currently open connections:

mysql> show processlist;
+---------+------------+-------------------+------------+---------+------+-------+------------------+
| Id      | User       | Host              | db         | Command | Time | State | Info             |
+---------+------------+-------------------+------------+---------+------+-------+------------------+
| 6297128 | root       | localhost         | NULL       | Query   |    0 | NULL  | show processlist |
| 6308321 | faqwpblogu | 10.10.29.66:42945 | lesaibkfaq | Sleep   |    1 |       | NULL             |
| 6308323 | faqwpblogu | 10.10.29.74:46993 | lesaibkfaq | Sleep   |    0 |       | NULL             |
| 6308325 | faqwpblogu | 10.10.29.74:46995 | lesaibkfaq | Sleep   |    1 |       | NULL             |
| 6308326 | faqwpblogu | 10.10.29.74:46996 | lesaibkfaq | Sleep   |    0 |       | NULL             |
+---------+------------+-------------------+------------+---------+------+-------+------------------+
5 rows in set (0.00 sec)

The above output indicates four currently open connection for user called 'faqwpblogu' from app server located at 10.10.29.66 and 10.10.29.74.

 

Was this answer helpful?

« Back