Overview
This topic describes how to terminate sessions on an ApsaraDB RDS for MySQL instance.
Procedure
You can terminate sessions on an RDS instance by using one of the following methods:
Use the session management feature.
Use the kill command.
A privileged account can terminate all sessions. A standard account can terminate only the current session. For more information about account permissions, see Account types.
Use the session management feature to terminate sessions
Log on to the ApsaraDB RDS console. In the top navigation bar, select a region in which your RDS instance resides. Find the RDS instance and click the instance ID.
In the left-side navigation pane of the page that appears, choose Autonomy Services > Diagnostics.
Click the Session Management tab.
On the Session Management tab, view the information about the current sessions of the RDS instance and terminate unnecessary sessions by using the session termination feature. For more information, see Use the session management feature.
Use the kill command to terminate sessions
Connect to the RDS instance by using the MySQL command-line tool. For more information, see Use a client or the CLI to connect to an ApsaraDB RDS for MySQL instance.
NoteIf the number of connections to the RDS instance reaches the upper limit, you cannot connect to the RDS instance by using Data Management (DMS) or the MySQL command-line tool. In this case, we recommend that you terminate sessions by using the session management feature.
Execute the following statement to query current sessions and record the ID of the session that you want to terminate:
SHOW processlist;
The following sample output is returned.
Run the following command to terminate the session:
KILL [$ID];
Note[$ID] specifies the ID of the session that you want to delete.
The following sample output is returned.
What to do next
You can modify the wait_timeout
and interactive_timeout
parameters to optimize the timeout period for an RDS instance to automatically terminate connections. For more information, see Modify instance parameters.
The modification of the parameters only affects new sessions.
For connections in non-interactive mode, log on to the ApsaraDB RDS console and decrease the value of the
wait_timeout
parameter on the Parameters page. Thewait_timeout
parameter specifies the timeout period of a connection in non-interactive mode. Default value: 86400. Unit: seconds. The default value equals 24 hours. When a non-interactive connection is idle for a period of time that is longer than the value of thewait_timeout
parameter, the RDS instance automatically terminates the connection.For connections in interactive mode, log on to the ApsaraDB RDS console and decrease the value of the
interactive_timeout
parameter on the Parameters page. Theinteractive_timeout
parameter specifies the timeout period of a connection in interactive mode. Default value: 7200. Unit: seconds. The default value equals 2 hours. When an interactive connection is idle for a period of time that is longer than the value of theinteractive_timeout
parameter, the RDS instance automatically terminates the connection.
Application scope
ApsaraDB RDS for MySQL