Check The Number Of MySQL Open Database Connections on Linux Or Unix-like Server
Source: nixCraft
I‘m a new MySQL server user. My server is running on a CentOS Linux. How can I check the number of active MySQL connections on Linux based system?
You can use the following commands on Linux or Unix-like systems:
- mysqladmin
statuscommand - MySQL
show statuscommand netstatorsscommands
mysqladmin status command example
Open the terminal App or login to the remote server using ssh:
ssh [email protected]
Type the following command to get a short status message from the MySQL server:
mysqladmin status ## OR ## mysqladmin status -u root -p ## OR ## mysqladmin status -h db1.dbsysnet.com -u root -p
Sample outputs:
Uptime: 691356 Threads: 5 Questions: 83237956 Slow queries: 102736 Opens: 3585 Flush tables: 1 Open tables: 1019 Queries per second avg: 120.398
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 serverincludes both failed and successful connection attempts:
mysql> show status like 'Conn%';
Sample outputs:

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)
You have configured your MySql replication, next step is to perform maintenance and monitor your replication. Percona Toolkit for MySQL is a collection of advanced command-line tools to perform a variety of MySQL server and system tasks.
Nous sommes dans la situation où il faut redémarrer le serveur maitre