mysql: see all open connections to a given database?

Viewed 258557

With administrative permissions im mysql, how can I see all the open connections to a specific db in my server?

9 Answers

In MySql,the following query shall show the total number of open connections:

show status like 'Threads_connected';

From the monitoring context here is how you can easily view the connections to all databases sorted by database. With that data easily monitor.

SELECT DB,USER,HOST,STATE FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY DB DESC;
+------+-------+---------------------+-----------+
| DB   | USER  | HOST                | STATE     |
+------+-------+---------------------+-----------+
| web  | tommy | 201.29.120.10:41146 | executing |
+------+-------+---------------------+-----------+

If we encounter any hosts hots max connections and then not able to connect, then we can reset host tables by flushing it and is as follows:

FLUSH HOSTS;
Related