All Products
Search
Document Center

ApsaraDB for SelectDB:Connect to ApsaraDB for SelectDB using a MySQL client

Last Updated:Jul 17, 2026

ApsaraDB for SelectDB is compatible with the MySQL protocol, so you can connect to it using any MySQL-compatible client. You can use the command-line MySQL client to connect to an ApsaraDB for SelectDB instance.

Prerequisites

  • The target instance is in the Running state.

  • The MySQL client must use a connector compatible with MySQL 5.7.

  • Configure the network for theApsaraDB for SelectDB instance based on your client's network environment:

    • If your client is in the same VPC as the ApsaraDB for SelectDB instance, no special network configuration is required. You only need to obtain the VPC Endpoint of the ApsaraDB for SelectDB instance.

    • In other cases, you must Apply for Public Endpoint for the ApsaraDB for SelectDB instance. For more information, see Apply for and release a public endpoint.

      Note

      Using a public endpoint to access an ApsaraDB for SelectDB instance generates public network traffic. Public network traffic for ApsaraDB for SelectDB instances is free of charge.

  • The IP address of the MySQL client must be in the IP address whitelist of the target instance. For more information, see Configure an IP address whitelist.

Procedure

  1. Get the endpoint and port number of the instance.

    In the ApsaraDB for SelectDB console, go to the instance details page. Find the VPC Endpoint or Public Endpoint and the MySQL Port of the target instance.

  2. Connect to the instance.

    Using a public endpoint to access an ApsaraDB for SelectDB instance generates public network traffic. Public network traffic for ApsaraDB for SelectDB instances is free of charge.

    mysql -h <public_endpoint_or_VPC_endpoint> -P <mysql_port> -u <database_account> -p<password_of_database_account>

    Example:

    mysql -h selectdb-cn-*****.selectdbfe.rds.aliyuncs.com -P 9030 -u testdb -pselectdb123
  3. (Optional) After you connect to the instance, select the target cluster and list the databases.

    USE @test_cluster;
    show databases; 

    Expected output:

    +--------------------+
    | Database           |
    +--------------------+
    | test               |
    | test01             |
    +--------------------+

Related topics

For more visualization tools, see Data visualization.

FAQ

Q: What do I do if I receive the following error when connecting to the instance?

ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 2

A: Verify that your client's IP address is added to the instance's IP address whitelist. For more information, see Configure an IP address whitelist.