All Products
Search
Document Center

ApsaraDB RDS:Step 2: Connect to an ApsaraDB RDS for MySQL instance

Last Updated:Jun 24, 2026

After creating an ApsaraDB RDS for MySQL instance and a database, you must connect to the instance to manage data or connect your application server to the database to deploy services. This tutorial demonstrates how to log on directly with Data Management (DMS) or connect remotely with a command-line interface (CLI) or a client. Choose the method that best fits your needs.

Billing

  • Creating an ApsaraDB RDS for MySQL instance incurs fees for the instance specifications and storage. The fees vary based on parameters such as the billing method, instance series, specifications, storage type, and storage capacity.

  • The fees described in this tutorial do not include the costs of application servers or third-party clients used to connect to the ApsaraDB RDS instance.

Prerequisites

  • You have created an ApsaraDB RDS for MySQL instance, a database, and a privileged account on the instance. For more information, see Step 1: Create an ApsaraDB RDS for MySQL instance and configure a database.

    Important

    This tutorial uses the ApsaraDB RDS for MySQL instance, database, account, and password that you created and configured in the console by following Step 1: Create an ApsaraDB RDS for MySQL instance and configure a database. You can modify them based on your business requirements.

  • If you plan to log on to the database by using DMS, no additional preparation is required. You can proceed directly to the logon steps.

  • If you plan to connect to the database by using a command-line interface (CLI) or a client, you must configure an IP address whitelist for the instance and obtain the internal or public endpoint based on the access type. The following section describes the required operations:

    Configure an IP address whitelist and obtain the internal and public endpoints

    1. Configure an IP address whitelist

    To access the ApsaraDB RDS for MySQL instance, you must add your IP address or your application server's IP address to the instance's IP address whitelist. You must configure the IP address whitelist before you can obtain the internal or public endpoint.

    2. Select an access type

    For remote connections, use an internal endpoint if your environment meets the requirements. Otherwise, use a public endpoint. The requirements for internal network access and how to obtain the endpoints are as follows:

    Important

    To connect to an instance over the internal network, the following requirements must be met:

    • The Alibaba Cloud server you use to access the ApsaraDB RDS instance must be in the same region and Virtual Private Cloud (VPC) as the instance.

    • If both the server and the instance use the VPC network type, they must reside in the same VPC.

    Scenario

    Endpoint

    Method

    The requirements for an internal connection are met.

    Internal endpoint of the ApsaraDB RDS instance

    1. Log on to the ApsaraDB RDS console and go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the instance ID.

    2. Click View Details to view the RDS instance address and port number. In the Basic Information section, click View Connection Details next to Network Type.

    Note
    • The public endpoint is displayed only after you click Apply for Public Endpoint.

    • For cluster instances, modify the primary node address in the Cluster Read/Write Connection section and the secondary node address in the Cluster Read-only Connection section.

    You connect from an ECS instance, but the requirements for an internal connection are not met.

    Public endpoint of the ApsaraDB RDS instance

    You connect from a local device.

Method 1: Log on by using DMS

Data Management (DMS) is an all-in-one data management platform that supports the entire data lifecycle. It provides features such as global data asset management, data governance, database design and development, data integration, data development, and data consumption. DMS is designed to help enterprises efficiently and securely explore the value of data and accelerate digital transformation.

You can use DMS to quickly and easily log on to an ApsaraDB RDS for MySQL instance to manage and use data. You do not need to configure an IP address whitelist for the instance or select an access type.

  1. Go to the Instances page. In the top navigation bar, select the region where the instance resides. Then, click the instance ID.

  2. Click Log In to go to the DMS logon page.

  3. In the Log On to Instance dialog box, enter the logon information, and click Log On.

    • Select Access Mode. This tutorial uses Account + password login as an example.

      If you select the KMS Credential Logon option, see Integrate Data Management (DMS) with RDS Credentials.

    • Enter the Database Account and Database Password. This tutorial uses the privileged account dbuser and a user-defined password as an example.

    • Select Control Mode. This tutorial uses Flexible Management - Free Forever as an example.

      Note
      • Stable Change and Security Collaboration incur fees.

      • Compared to the Flexible Management (Free Forever) control mode, Stable Change and Security Collaboration provide more features and stronger database control capabilities. If you are trying out or evaluating the RDS MySQL product, we recommend that you select the Flexible Management mode.

  4. View the database. After you log on successfully, you can view the newly created database under Instances Connected on the left side of the DMS page. This tutorial uses the db_test1 database as an example. You can also double-click other databases to switch.

    Note
    • information_schema, MySQL, performance_schema, sys, and Recycle Bin are all system databases.

    • If the instance is listed but the destination database does not appear when you expand it, one of the following may be the cause:

      • The login account does not have access permissions for the target database: You can go to the Accounts page on the RDS instance details page to manually adjust account permissions.

      • The metadata is not synchronized. As a result, the database is not displayed in the navigation tree. You can hover over the instance you want to manage and click the image icon to the right of the instance name to refresh the database list.

      To quickly synchronize the database schema, you can use the schema design feature of DMS.

Method 2: Connect by using the CLI

If you prefer to use commands to manage your database and want to connect from an Alibaba Cloud ECS instance or a local server, you can connect to your ApsaraDB RDS for MySQL instance by using the CLI. This tutorial uses a Linux operating system as an example.

Important
  1. Log on to the application server that you want to use to connect to the ApsaraDB RDS instance. You can connect from a local server or log on to an Alibaba Cloud ECS instance.

  2. Run the database connection command and enter the password to access the ApsaraDB RDS for MySQL instance. In the command, -h specifies the endpoint of the ApsaraDB RDS instance, -P specifies the port of the ApsaraDB RDS instance, -u specifies the username, and -p prompts you for the password.

    # Connection command template
    mysql -h <endpoint> -P <port> -u <username> -p
    # Connection command example
    mysql -h rm-bp**************.mysql.rds.aliyuncs.com -P 3306 -u dbuser -p
    • Enter the endpoint. You must determine whether the requirements for an internal connection are met and enter the appropriate endpoint. This tutorial uses an internal endpoint as an example. For more information about how to obtain the internal and public endpoints of an instance, see the Prerequisites section of this topic.

    • Enter the port. This tutorial uses port 3306 as an example.

    • Enter the username. This tutorial uses the privileged account dbuser as an example.

    • Press the Enter key. At the Enter password prompt, enter the password of the privileged account and press the Enter key again.

  3. When the CLI displays the following welcome message, you are connected to the ApsaraDB RDS for MySQL instance. You can then perform database operations.

    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 51325
    Server version: 8.0.18 Source distribution

Method 3: Connect by using a client

If you are not familiar with server commands, you can connect to your ApsaraDB RDS for MySQL instance by using a standard third-party client. This tutorial uses MySQL Workbench 8.0.29 as an example.

Important
  1. Open MySQL Workbench and choose Database > Connect to Database.

  2. On the Connect to Database page, enter the required endpoint and account information.

    • For Connection Method, select Standard(TCP/IP), which is used as an example in this tutorial.

    • Hostname: You must determine whether the requirements for an internal connection are met and enter the appropriate endpoint. This tutorial uses an internal endpoint as an example.

    • Port: This tutorial uses port 3306 as an example.

    • Username: This tutorial uses the privileged account dbuser as an example.

    • Password: Enter your custom password.

  3. Click OK to connect to the ApsaraDB RDS for MySQL instance. You can then perform database operations.

Common errors

mysql command not found

This error occurs because MySQL is not installed. You can run one of the following commands to install MySQL:

  • CentOS: Run sudo yum install mysql.

  • Ubuntu: Run sudo apt-get update and then sudo apt install mysql-server.

SSL connection error: SSL is required but the server doesn't support it

With some versions of MySQL Workbench, Standard TCP/IP connections require SSL encryption. You can download the version used in this tutorial (MySQL Workbench 8.0.29) to establish a standard connection.

Error 10060: Can't connect to MySQL server on 'rm-bpxxx.mysql.rds.aliyuncs.com'(10060)

  • (Most common) The IP address whitelist for the ApsaraDB RDS instance is configured incorrectly. For more information, see Configure an IP address whitelist.

  • (Less common) You use an internal endpoint to connect, but the requirements for an internal connection are not met. For example, the ECS instance and the ApsaraDB RDS instance are not in the same VPC. In this case, obtain and use a public endpoint.

Cannot Connect to Database Server

  • (Most common) The IP address whitelist for the ApsaraDB RDS instance is configured incorrectly. For more information, see Configure an IP address whitelist.

  • (Less common) You use an internal endpoint to connect, but the requirements for an internal connection are not met. For example, the ECS instance and the ApsaraDB RDS instance are not in the same VPC. In this case, obtain and use a public endpoint.

Your connection attempt failed for user 'xx" to the MySQL server

  • (Most common) The IP address whitelist for the ApsaraDB RDS instance is configured incorrectly. For more information, see Configure an IP address whitelist.

  • (Less common) You use an internal endpoint to connect, but the requirements for an internal connection are not met. For example, the ECS instance and the ApsaraDB RDS instance are not in the same VPC. In this case, obtain and use a public endpoint.

Destination Host Unreachable error when you ping the internal endpoint of the ApsaraDB RDS instance

Cause: Route conflicts. For information about how to resolve this issue, see What do I do if I cannot ping the internal endpoint of an ApsaraDB RDS instance?.

Access denied for user 'xxx'@'xxx'(using password:YES)

The account or password that you entered is incorrect. You can manage accounts and passwords on the Accounts page in the RDS console.

Unknown MySQL server host 'xxx'(11001)

Cause: The entered endpoint of the ApsaraDB RDS instance is incorrect. The endpoint must be in the rm-xxxxxx.mysql.rds.aliyuncs.com format.

FAQ

  • Q: I use Function Compute (FC). How can I retrieve data from an ApsaraDB RDS instance?

    A: You can install third-party dependencies for a function and use built-in modules to retrieve data from the ApsaraDB RDS instance. For more information, see Install third-party dependencies.

  • Q: After I connect to the database, how do I import an SQL file?

    A: If you need to quickly import a large amount of data from a file (in the SQL, CSV, or Excel format), you can use the data import feature of DMS.

Related documents