This topic describes how to connect to a Serverless StarRocks instance using a MySQL client.
Prerequisites
A Serverless StarRocks instance has been created. For more information, see Create an instance.
Connect to StarRocks using a MySQL client on an ECS instance
For more information about how to create an ECS instance, see Quick start.
If you use an internal network connection, ensure that the MySQL client and the StarRocks instance are in the same virtual private cloud (VPC) and vSwitch.
Add the IP address of the instance that hosts the MySQL client to a security group. The default port for the frontend (FE) node is 9030.
Install the MySQL client. For more information, see Installing MySQL Shell.
In the MySQL client, run the following command to connect to the StarRocks instance.
mysql -hfe-c-*****.starrocks.aliyuncs.com -P 9030 -uadmin -pAfter the connection is established, you can perform operations.
Connect to StarRocks using an open source MySQL client
Step 1: Download the MySQL client and install the database
Download the MySQL client.
Run the following command to decompress the installation package.
tar -zxvf mysql-5.6.40-linux-glibc2.12-i686.tar.gzRun the following command to copy the decompressed mysql directory to the local software directory on your system.
cp mysql-5.6.17-linux-glibc2.5-i686 /usr/local/mysql -rImportantDo not add a forward slash (/) to the end of the
/usr/local/mysqldirectory path.Run the following command to add the mysql system group and the mysql user.
sudo groupadd mysql sudo useradd -r -g mysql mysqlInstall the database.
Run the following command to navigate to the MySQL software installation directory.
cd /usr/local/mysqlRun the following command to change the ownership of the current directory to the mysql user.
chown -R mysql:mysql ./Run the following command to install the database.
./bin/mysql_install_db --user=mysqlAlternatively, you can perform an initialization.
sudo bin/mysqld --initialize --user=mysqlRun the following command to change the ownership of the current directory to the root user.
chown -R root:root ./Run the following command to change the ownership of the data directory to the mysql user.
chown -R mysql:mysql dataRun the following command to copy the file.
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
Run the following command to start the MySQL service.
sudo service mysql start
Step 2: Connect to the StarRocks instance
Run the following command to connect to the StarRocks instance.
/usr/local/mysql/bin/mysql -u admin -p -h fe-c-xxxxxx.starrocks.aliyuncs.com -P 9030fe-c-xxxxxxx.starrocks.aliyuncs.com is the public network address of the FE node of the EMR Serverless StarRocks instance.
You can find the address on the StarRocks instance's Instance Details page.