All Products
Search
Document Center

:How do I terminate sessions on an ApsaraDB RDS for MySQL instance?

Last Updated:Dec 06, 2022

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 Data Management (DMS).

  • Use the kill command.

Important

A privileged account can terminate all sessions. A standard account can terminate only the current session. For more information about account permissions, see Create an account on an ApsaraDB RDS for MySQL instance.

Use DMS to terminate sessions on an RDS instance

  1. Log on to the RDS instance. For more information, see Use DMS to log on to an ApsaraDB RDS for MySQL instance.

  2. Right-click the instance ID and choose Performance > Instance session.

  3. In the dialog box that appears, select the new version of the DAS console and authorize the user to access DAS. Authorization is required only for the first logon.

  4. Click Kill Selected to terminate the session that you select. You can select multiple sessions.

Use the kill command to terminate sessions on an RDS instance

  1. Connect to the RDS instance by using the MySQL command-line tool. For more information, see Use a database client or the CLI to connect to an ApsaraDB RDS for MySQL instance.

    Note

    When the number of connections to the RDS instance reaches the upper limit, you cannot connect to the RDS instance by using DMS or the MySQL command-line tool. In this case, we recommend that you set the wait_timeout parameter to a small value (unit: seconds), such as 60, in the ApsaraDB RDS console. If you set this parameter to 60, the RDS instance automatically terminates the connections that are idle for more than 60 seconds. This way, you can connect to the RDS instance by using DMS or the MySQL command-line tool.

  2. Execute the following statement to record the ID of the session that you want to terminate:

    show processlist;

    The following figure shows a sample output.

Query sessions by using the MySQL command-line tool
  1. Run the following command to terminate the session:

kill [$ID];
Note

The [$ID] parameter specifies the ID of the session that you want to terminate.

The following figure shows a sample output.

Terminate sessions by using the kill command

Applicable scope

  • ApsaraDB RDS for MySQL