Show Global Maximum SQL Connections in Use
Luke Hebert
- 2 minutes read - 249 wordsWhen you’re sizing a database server or troubleshooting intermittent “Too many connections” errors, you need to know how many simultaneous connections your MySQL instance has actually handled. The max_used_connections status variable gives you that number directly.
The Command
Run this as a user with PROCESS privilege (typically root or a DBA account):
SHOW GLOBAL STATUS LIKE 'max_used_connections';Example output:
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| Max_used_connections | 142 |
+----------------------+-------+What the Number Means
- Value: The highest number of concurrent client connections that have been active at any single moment since the server last started.
- Scope: Global, not per-session. It resets to zero on a server restart.
- Comparison: Compare this against your
max_connectionssystem variable (SHOW VARIABLES LIKE 'max_connections';) to see how close you are to the ceiling.
When to Check This
- After a traffic spike or application deploy, to confirm you have headroom.
- Before raising
max_connections, to see whether the current limit is actually being hit. - During incident response for connection-pool exhaustion errors.
Related Variables Worth Checking Together
SHOW GLOBAL STATUS LIKE 'Threads_connected';
SHOW GLOBAL STATUS LIKE 'Threads_running';
SHOW VARIABLES LIKE 'max_connections';Threads_connected tells you the current live count, while max_used_connections tells you the historical peak. Together they give a clear picture of whether your connection budget is adequate.
If max_used_connections is consistently close to max_connections, consider increasing the limit, tuning your application’s connection pool, or adding a connection proxy like ProxySQL to reduce the number of direct connections to the server.