All Products
Search
Document Center

ApsaraDB for SelectDB:Connect to an ApsaraDB for SelectDB instance by using a MySQL client

Last Updated:Mar 28, 2026

ApsaraDB for SelectDB is compatible with the MySQL protocol, so you can connect to it using a standard MySQL client.

Prerequisites

Before you begin, ensure that you have:

  • An ApsaraDB for SelectDB instance in the Running state

  • A MySQL client whose database connector is compatible with MySQL 5.7

  • Network access configured based on where your MySQL client runs:

    • If the client runs on an Elastic Compute Service (ECS) instance in the same virtual private cloud (VPC) as the SelectDB instance, no additional network configuration is needed — get the VPC endpoint from the console

    • In all other cases, apply for a public endpoint for the instance

  • The client's IP address added to the instance's IP address whitelist

Connecting over a public endpoint generates Internet traffic. Alibaba Cloud does not charge for inbound or outbound Internet traffic.

Connect to the instance

Step 1: Get the endpoint and port

Log on to the ApsaraDB for SelectDB console. On the Instance Details page, locate the VPC endpoint, public endpoint, and MySQL port.

Step 2: Run the connection command

mysql -h <endpoint> \      # VPC endpoint or public endpoint from the console
      -P <MySQL port> \    # MySQL port from the console
      -u <database account> \
      -p<account password> # No space between -p and the password
ParameterDescription
-h <endpoint>VPC endpoint or public endpoint from the console
-P <MySQL port>MySQL port from the console
-u <database account>Database account name
-p<account password>Account password (no space between -p and the password)

Example:

mysql -h selectdb-cn-*****.selectdbfe.rds.aliyuncs.com -P 9030 -u testdb -pselectdb123

Step 3 (Optional): Query databases in a cluster

After connecting, select a cluster and list its databases:

USE @test_cluster;
show databases;

Expected output:

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

What's next

To connect using a data visualization tool, see Data visualization.

FAQ

Why do I get `ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 2`?

The instance blocked your connection because your client's IP address is not in the whitelist. Add it to the IP address whitelist and retry. See Configure an IP address whitelist.