All Products
Search
Document Center

ApsaraDB for MyBase:Connect to a MyBase for MySQL instance

Last Updated:Jun 20, 2026

This topic explains how to connect to an ApsaraDB MyBase for MySQL instance using a database client or the command-line interface (CLI).

Prerequisites

Before you begin, complete the following tasks:

Connect using a database client

You can use any standard MySQL database client to connect to an ApsaraDB MyBase for MySQL instance. This topic uses MySQL Workbench as an example. To download MySQL Workbench, visit the MySQL Workbench download page.

  1. On an ECS instance or a local computer, open MySQL Workbench and choose Database > Connect to Database.

  2. Enter the connection information.

    Parameter

    Description

    Hostname

    Enter the endpoint of the instance. To view the internal and public endpoints of the instance, see View endpoints and port numbers.

    • If you connect from an ECS instance that meets the internal network requirements, use the internal endpoint. The requirements are as follows:

      • The ECS instance and the ApsaraDB MyBase for MySQL instance are in the same region.

      • The ECS instance and the ApsaraDB MyBase for MySQL instance use the same network type. If both use a Virtual Private Cloud (VPC), they must be in the same VPC.

    • If you connect from an ECS instance that does not meet the internal network requirements, use the public endpoint.

    • If you connect from your local machine, use the public endpoint.

    Port

    Enter the port number of the instance. To find the port number, see View endpoints and port numbers.

    Username

    Enter the username for the database account. To find the username, see Create a database account.

    Password

    Enter the password for the database account.

  3. (Optional) Click Test Connection to verify the settings.

  4. Click OK to connect to the instance.

Connect using the CLI

  1. Log on to the server from which you want to connect to the instance, such as an ECS instance or an on-premises server.

  2. Run the following command to connect to the instance:

    mysql -h <endpoint> -P <port> -u <username> -p      // Use -P to specify the port and -p to be prompted for the password.

    Parameter

    Description

    endpoint

    The endpoint of the instance. To view the internal and public endpoints of the instance, see View endpoints and port numbers.

    • If you connect from an ECS instance that meets the internal network requirements, use the internal endpoint. The requirements are as follows:

      • The ECS instance and the ApsaraDB MyBase for MySQL instance are in the same region.

      • The ECS instance and the ApsaraDB MyBase for MySQL instance use the same network type. If both use a VPC, they must be in the same VPC.

    • If you connect from an ECS instance that does not meet the internal network requirements, use the public endpoint.

    • If you connect from your local machine, use the public endpoint.

    port

    The port number of the instance. To find the port number, see View endpoints and port numbers.

    username and password

    The username and password for the database account. To find the username, see Create a database account.

    A successful connection returns the following output:

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