The max_user_connections parameter sets the maximum number of connections allowed for a database on an ApsaraDB RDS for MySQL instance. When this limit is reached, new connections are rejected with one of the following errors:
has more than 'max_user_connections' active connectionsUser 'xxx' has exceeded the 'max_user_connections' resource
To resolve this, identify which sessions are consuming connections, then either release them or raise the connection limit.
Identify the cause
Before adjusting max_user_connections, confirm that the connection limit is the problem and find out which sessions are holding connections.
Check the current connection limit
To see the current value of max_user_connections, run:
show variables like 'max_user_connections';View active sessions
Use one of the following methods to see which sessions are open.
Using the ApsaraDB RDS console:
Log on to the ApsaraDB RDS console. In the top navigation bar, select the region where the instance resides. Find the instance and click its ID.
In the left-side navigation pane, choose Autonomy Services > Diagnostics.
On the Diagnostics page, click Session Management to view all sessions, active sessions, and abnormal sessions, including details such as User, Hostname, Execution Duration (s), and Status.
For more information, see Session management.
Using SQL:
To list all active threads and identify which accounts and source IP addresses are holding connections, run:
SHOW PROCESSLIST;The Host column shows the source IP address of each connection.
If the connection limit has been reached and you cannot open a new session, connect from an Elastic Compute Service (ECS) instance or use Data Management (DMS), which can reuse historical sessions already established to the RDS instance. For more information, see How do I connect to an ApsaraDB RDS instance? and Use DMS to log on to an ApsaraDB RDS for MySQL instance.
Using SQL Explorer and Audit:
If you need a historical record of which accounts and IP addresses have been executing statements, enable the SQL Explorer and Audit feature. It records SQL statements from the database kernel, the accounts and IP addresses that executed them, and execution details — without affecting instance performance.
The SQL Explorer and Audit feature is a paid feature. For billing details, see Billing rules.
To enable it:
Log on to the ApsaraDB RDS console. In the top navigation bar, select the region where the instance resides. Find the instance and click its ID.
In the left-side navigation pane, choose Autonomy Services > SQL Explorer and Audit.
Enable the SQL Explorer and Audit feature.
For more information, see Use the SQL Explorer and Audit feature.
Solution
Review active sessions. In the ApsaraDB RDS console, go to Autonomy Services > Diagnostics > Session Management and view the details of the established sessions. For more information, see Session management.
Check the connection limit. Use the console or the SQL statement above to confirm the current value of
max_user_connections. To view it in the console:Log on to the ApsaraDB RDS console and click the instance ID.
In the left-side navigation pane, click Parameters.
On the Modifiable Parameters tab, find
max_user_connectionsand note its current value.
Raise the connection limit. After confirming that the instance has enough memory, increase the value of
max_user_connections. For instructions, see Modify the parameters that specify the maximum number of connections.If the problem persists, try the following:
Investigate the root cause of the high connection count. See What do I do if the number of connections to an ApsaraDB RDS for MySQL instance reaches the upper limit?
Restart the instance to release all connections. See Restart an RDS instance.