Connect to an ApsaraDB MyBase for MySQL instance using MySQL Workbench or the MySQL command-line interface (CLI).
Prerequisites
Before you begin, ensure that you have:
Get connection information
Before connecting, retrieve the endpoint, port number, and database account credentials for your instance. For more information about how to view the internal and public endpoints and port number of your instance, see View the private and public endpoints and the port numbers of an ApsaraDB MyBase for SQL Server instance.
Which endpoint to use:
| Connection scenario | Endpoint to use |
|---|---|
| From an Elastic Compute Service (ECS) instance in the same region as the MyBase instance, where both are of the same network type (if both are Virtual Private Cloud (VPC) type, they must reside in the same VPC) | Internal endpoint |
| From an ECS instance where internal network conditions are not met | Public endpoint |
| From a local computer | Public endpoint |
Connect using MySQL Workbench
Download MySQL Workbench from the MySQL Workbench download page if you have not already done so.
-
Start MySQL Workbench on your ECS instance or local computer, then choose Database > Connect to Database.
-
Enter the connection details.
Parameter Description Hostname The internal or public endpoint of the instance Port The port number of the instance Username The database account name Password The password for the database account 
-
(Optional) Click Test Connection to verify connectivity before saving.
-
Click OK. If the connection succeeds, a confirmation message appears.

Connect using the CLI
Run the following command from your ECS instance or on-premises server:
mysql -h <Endpoint> -P <Port> -u <Username> -p<Password>
-P(uppercase) specifies the port number.-p(lowercase) specifies the password. There is no space between-pand the password value.
Replace the placeholders with your actual values:
| Placeholder | Description |
|---|---|
<Endpoint> |
The internal or public endpoint of the instance |
<Port> |
The port number of the instance |
<Username> |
The database account name |
<Password> |
The password for the database account |
If the connection succeeds, a message is returned, as shown in the following figure.