All Products
Search
Document Center

E-MapReduce:Use a MySQL client to connect to a StarRocks instance

Last Updated:Mar 26, 2026

E-MapReduce (EMR) Serverless StarRocks supports three connection methods: EMR StarRocks Manager (a browser-based GUI), the MySQL client on an Elastic Compute Service (ECS) instance, and an open source MySQL client. Choose the method that matches your environment.

Prerequisites

Before you begin, ensure that you have:

  • A Serverless StarRocks instance. For more information, see Create an instance

  • (For the ECS method) The ECS instance and the StarRocks instance in the same virtual private cloud (VPC) and vSwitch, if you plan to use the internal endpoint

  • (For the ECS method) The IP address of the ECS instance added to the security group. The default port for the StarRocks frontend node (FE) is 9030

Connect using EMR StarRocks Manager

EMR StarRocks Manager is a web-based client built into the EMR console. No local installation is required.

Navigate to StarRocks Manager

  1. Log on to the EMR console.

  2. In the left-side navigation pane, choose EMR Serverless > StarRocks.

  3. In the top navigation bar, select the region where your instance resides.

  4. Click StarRocks Manager, or find the instance and click Connect in the Actions column.

For more information about StarRocks Manager, see Use EMR StarRocks Manager to connect to a StarRocks instance.

Create a connection

  1. On the New Connection tab, fill in the following parameters.

    image.png

    Parameter

    Example

    Description

    Region

    China (Hangzhou)

    The region in which the EMR Serverless StarRocks instance resides.

    Instance

    StarRocks_Serverlesss

    The name of the EMR Serverless StarRocks instance.

    Connection Name

    Connection_Serverlesss

    The custom name of the connection. The name must be 1 to 64 characters in length and can contain letters, digits, hyphens (-), and underscores (_).

    Username

    admin

    The username used to log on to the instance. The default initial username is admin. You can use this username or create another user based on your requirements.

    Password

    The password set when you created the EMR Serverless StarRocks instance.

  2. Click Test Network Connectivity.

  3. After the test passes, click OK.

Use an existing connection

Important

Make sure the connected instance still exists before reusing a connection. If the instance has been deleted, create a new connection instead.

On the Existing Connections tab, find the connection and click Connect in the Actions column.

image

Connect using a MySQL client on an ECS instance

For information about creating an ECS instance, see Getting started with ECS.

  1. Install the MySQL client on the ECS instance. For installation instructions, see Installing MySQL Shell.

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

    # Replace fe-c-*****.starrocks.aliyuncs.com with the endpoint of your instance.
    # The default FE port is 9030. The default admin username is admin.
    mysql -hfe-c-*****.starrocks.aliyuncs.com -P 9030 -uadmin -p
  3. Run queries or perform other operations.

Connect using an open source MySQL client

The public endpoint of your StarRocks instance is available on the Instance Details tab in the EMR console.

Step 1: Download and install the MySQL client

  1. Download the MySQL client.

  2. Decompress the installation package:

    tar -zxvf mysql-5.6.40-linux-glibc2.12-i686.tar.gz
  3. Copy the decompressed directory to /usr/local/mysql:

    Important

    The path /usr/local/mysql must not end with a forward slash (/).

    cp mysql-5.6.17-linux-glibc2.5-i686 /usr/local/mysql -r
  4. Add a MySQL group and user:

    sudo groupadd mysql
    sudo useradd -r -g mysql mysql
  5. Install the MySQL client:

    # Navigate to the installation directory
    cd /usr/local/mysql
    
    # Set the directory owner to mysql
    chown -R mysql:mysql ./
    
    # Install the MySQL client (or use the initialization command below)
    ./bin/mysql_install_db --user=mysql
    
    # Alternative: initialize instead of install
    # sudo bin/mysqld --initialize --user=mysql
    
    # Reset directory ownership to root
    chown -R root:root ./
    
    # Set the data directory owner to mysql
    chown -R mysql:mysql data
    
    # Copy the service script
    cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
  6. Start the MySQL service:

    sudo service mysql start

Step 2: Connect to the StarRocks instance

Run the following command to connect:

# Replace fe-c-xxxxxx.starrocks.aliyuncs.com with the public endpoint of your instance's FE.
# View the endpoint on the Instance Details tab in the EMR console.
/usr/local/mysql/bin/mysql -u admin -p -h fe-c-xxxxxx.starrocks.aliyuncs.com -P 9030