To check the number of open database connections in MySQL on a Linux or Unix-like server, you can use the following steps:
mysql
command:mysql -u username -p
Replace username
with the username of the MySQL account you want to use to connect. You will be prompted for the password for the account.
SHOW STATUS WHERE `variable_name` = 'Threads_connected';
This will output a line similar to the following:
+-------------------+-------+ | Variable_name | Value | +-------------------+-------+ | Threads_connected | 2 | +-------------------+-------+
The Value
column shows the number of open database connections.
SHOW VARIABLES WHERE `variable_name` = 'max_connections';
This will output a line similar to the following:
+-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 150 | +-----------------+-------+
The Value
column shows the maximum number of connections that the MySQL server is configured to allow.