tencent cloud

TDSQL-C for MySQL

DocumentationTDSQL-C for MySQLOperation GuideDatabase ConnectionConnecting to ClusterConnecting to Cluster at Private or Public Network Address from Linux CVM Instance

Connecting to Cluster at Private or Public Network Address from Linux CVM Instance

Download
Focus Mode
Font Size
Last updated: 2026-05-15 14:27:50
TDSQL-C for MySQL supports instance-level independent IP addresses. This means you can connect to a specific instance using the IP address of the read-write instance or any read-only instance within the cluster. This document describes how to connect to any instance in a cluster from a Linux CVM using a private or public network address.

Prerequisites

Prepare a TDSQL-C for MySQL cluster. For details, see Create Cluster.
A database cluster account has been created. For details, see Create Database Account.

Step 1: Querying the Private/Public IP Address of the Instance to Connect To

1. Log in to the TDSQL-C for MySQL console.
2. On the cluster list page, perform operations based on the actual view mode used:
Tab View
List View
1. Click the target cluster in the cluster list on the left to go to the cluster management page.
2. On the cluster details page, locate the instance for which you need to query the private/public IP address. You can view the instance's private/public IP address under its corresponding network.

1. In the cluster list, locate the target cluster. Click Cluster ID or Manage in the Operation column to go to the cluster management page.
2. On the cluster management page, select the read-write or read-only instance on the instance list page, and you can view the instance private and public network IP address under Private/Public Network Address.


Step 2: Connecting to the Target Instance in the Cluster

1. Log in to the Linux CVM. For details, see Quickly Configuring the Linux CVM.
2. Using a CVM with CentOS 7.2 64-bit as an example, run the following command to install the MySQL client.
yum install mysql
The prompt Complete! indicates that the MySQL client installation is complete.


3. Select the corresponding operation based on the connection method used:
For private network connections:
3.1 Run the following command to log in to the TDSQL-C for MySQL cluster.
mysql -h hostname -P port -u username -p
hostname: Replace it with the private network address of the target instance in the TDSQL-C for MySQL cluster. For the method to query the private network address, see Step 1.
port: Replace it with the private network port number.
username: Replace it with the account name created in Prerequisites. The default account name root is used as an example here.
Example: The private network address is 10.0.168.14:5308, the account name is root, and the connection command to enter is mysql -h 10.0.168.14 -P 5308 -u root -p.
3.2 Enter the password for the account specified in the command above after the prompt Enter password:. If you have forgotten the password, see Reset Password to change it. In this example, the prompt MySQL [(none)]> indicates a successful login to TDSQL-C for MySQL.


For public network connections:
3.3 Run the following command to log in to the TDSQL-C for MySQL cluster.
mysql -h hostname -P port -u username -p
hostname: Replace it with the public network address of the target instance in the TDSQL-C for MySQL cluster. For the method to query the public network address, see Step 1. If the public network address is not enabled, see Enable or Disable Public Network Address.
port: Replace it with the public network port number.
username: Replace it with the account name for public network connections. We recommend that you create a separate account in the console for easier connection control and management.
3.4 Enter the password for the public network connection account name after the prompt Enter password:. If you have forgotten the password, see Reset Password to change it. In this example, the hostname is 59281c4exxx.myqcloud.com, and the public network port number is 15311.


4. Under the MySQL [(none)]> prompt, you can send SQL statements to the target TDSQL-C for MySQL server for execution. For specific commands, see mysql Client Commands. In the figure below, show databases;
is used as an example:




FAQs

Are Private and Public Network Connections Charged?

Private and public network connections are free to use and are not currently charged.

How to Reset and Log In to the Cluster If You Forget Your Username and Password

You can view the account name you created for connecting to the cluster under Account Management on the cluster management page in the TDSQL-C for MySQL console. If you forget the password, you can reset it and then log in to the cluster.


Do I Need to Configure a Security Group for the Cluster When a Connection to TDSQL-C for MySQL is Established via a Private or Public Network?

Configure a security group. For detailed steps, see Configure Security Group. Note that if the public network is enabled, the private network access port must be allowed in the configured security group rules when a connection is established via the public network.

What Should I Do If I Cannot Log In to a Linux Instance Due to Improper Security Group Rule Configuration on the CVM?

If the security group rules of your CVM are not properly matched, for example, if the corresponding port is not allowed, preventing you from logging in to the Linux instance, you can use the Security Group (Port) Verification Tool to check the connectivity of the security group currently configured for the instance.

You can use the one-click detection to identify the possible causes of login failures. Note that the port numbers that need to be allowed depend on the operating system of the CVM you are using. For example, for Linux CVMs, the port is typically 22 or 36000, and for Windows CVMs, the port is typically 3389.

On the CVM instance details page, choose Security Group > Modify rule, and then allow the corresponding port. For detailed operations, see Add Security Group Rules.

What Other Settings Can Cause Cluster Connection Failures?

If you cannot connect to the cluster, check whether the CVM and TDSQL-C for MySQL are under the same Tencent Cloud account, in the same region, and on the same VPC network. You must ensure that these three settings are the same to connect to the cluster normally. For more information on troubleshooting connection-related issues, see Troubleshooting > Connection Issues.

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback