tencent cloud

TencentDB for MySQL

CCN Connection

Download
Focus Mode
Font Size
Last updated: 2026-06-10 11:34:37
This document describes how to connect to a database using CCN.

Background

After a TencentDB for MySQL instance is created, if your CVM and the instance reside in different VPCs (including same/different accounts, same/different regions), you can connect to the database using CCN. Under the same Tencent Cloud account, if you purchase a Lighthouse server, note that Lighthouse uses a VPC automatically assigned by Tencent Cloud for network isolation. By default, the private network of a Lighthouse server does not interconnect with a TencentDB for MySQL instance residing in a VPC. Therefore, you cannot directly access the TencentDB for MySQL instance from the Lighthouse server. You must connect to the database by associating a CCN.
Connection Method
Use Case
Description
Billed or not
The CVM and MySQL belong to the same Tencent Cloud root account, reside in the same region, and are within the same VPC. For details, see Scenario 1.
The private network is high-speed with low latency.
Currently free of charge
Use the public network for connection in scenarios where the private network connection is unavailable. For details, see Scenario 2.
Note:
Connections over the public network are susceptible to network impacts. If you have high network requirements, we recommend using private network connections or CCN connections.
It supports third-party applications in connecting to the service.
The public network address must be enabled manually.
Enabling the public network address exposes your database service to the public network, which may lead to the database being compromised or attacked.
It is suitable for database development or auxiliary management but is not recommended for production business connections. This is because uncontrollable factors, such as DDoS attacks or sudden high-traffic access, may cause the public network connection to become unavailable.
Currently free of charge
CCN connection
The CVM and MySQL are in different VPCs, or you can use Lighthouse to connect to MySQL. For details, see Scenario 3.
Full network interconnection.
Low latency and high-speed transmission.

Preparations

Prepare a MySQL instance. For details, see Create MySQL Instance.
Prepare a CVM. This document uses Lighthouse as an example. For details, see Quickly Create a Linux Lighthouse.

Precautions

The private network interconnection feature for Lighthouse is free of charge. You only need to pay attention to the billing information for CCN. For details, see CCN Billing Overview. Within the same region, bandwidth of 5 Gbps or less is free. To achieve cross-region private network interconnection, you need to purchase non-cross-border bandwidth in CCN.
Lighthouse does not support cross-border private network interconnection by associating with a CCN, even if cross-border bandwidth has been purchased for that CCN.
Under the same account:
All Lighthouse instances within the same region reside in the same VPC. A VPC can be associated with only one CCN at a time.
Lighthouse instances in different regions reside in different VPCs. Each VPC must be associated with a CCN separately.
If no Lighthouse instance exists in a region, you cannot perform the operation to associate with a CCN in that region.

Operation Guide

1. Log in to the Lighthouse console and select Private Network Interconnection in the left sidebar.
2. Select the region where your TencentDB for MySQL instance resides, and then apply for Association with CCN.

3. In the Association with CCN window that pops up, select Create CCN instance.

4. Complete the creation of the CCN instance in the pop-up window. Then, return to the Associate CCN page under Lighthouse Private Network Interconnection. You can refresh the page to see the newly created CCN instance. Finally, click OK.
Note:
Only CCNs under the same account can be associated.
After the association request is submitted, please log in to the CCN console within 7 days to approve the request. Otherwise, the request will expire after 7 days, and you will need to submit a new association request.
5. Log in to the CCN console and click the target CCN ID to go to the CCN details page.
6. On the CCN details page, select Agree on the right side of the row for the association request.
The VPC instance for Lighthouse is tagged with the remark "Lighthouse VPC" by default. Please make your selection accordingly.
7. In the pop-up window, add the VPC network address of the target TencentDB for MySQL instance. Click **Add Instance**, select the region and VPC, and then click OK. The status of the region will be displayed as "Connected" on the Private Network Interconnection page.
8. Return to the Private Network Interconnection page in the Lighthouse console and refresh it. The connection status will be displayed as successful.
9. In the CCN console, click the target CCN ID to go to the CCN details page. Check whether the routes are valid. If any route is in the disabled state, enable it.
10. In the Lighthouse console, locate the target Lighthouse instance. Click Log in, select password login, enter the username, port, and password, and then click Log in.

11. After successful login, run the following command to download and install MySQL.
Method 1 (If Method 1 fails, proceed with Method 2):
yum install mysql -y

Method 2 (If Method 1 succeeds, you can ignore Method 2):
Run the following command to download and install MariaDB.
yum -y install mariadb-server
After successful installation, run the following command to start MariaDB. You can then use MySQL.
systemctl start mariadb
12. Run the following command to connect to and log in to TencentDB for MySQL.
mysql -h <private network ip address> -u <username, default root> -P <port number, default 3306> -p
<private IP address>: Replace it with the private network address of the target MySQL database instance. You can view the private network address on the instance details page in the TencentDB for MySQL console.

<username, default root>: Replace it with the account name of the target MySQL database instance. The default account name is root.

<private network port number>: Replace it with the private network port number of the target MySQL database instance. The default port is 3306. If you have modified the port number, you can view the new private network port number on the instance details page in the TencentDB for MySQL console.

13. After the connection is successful, the page appears as shown below.


FAQs

Is There a Charge for CCN Connections?

Using CCN incurs fees. For details, see CCN Billing Overview.

When to Use CCN to Connect to TencentDB for MySQL?

1. If your CVM and TencentDB for MySQL instance reside in different VPCs (including same/different accounts, same/different regions), you can connect to the database using CCN.
2. If you purchase a Lighthouse server, you need to connect to the database using CCN.

How to Achieve Private Network Interconnection for Lighthouse?

Lighthouse uses a VPC automatically assigned by Tencent Cloud for network isolation. By default, its private network does not interconnect with the private networks of other Tencent Cloud resources within the VPC, such as CVM and cloud databases. You need to associate it with CCN to enable interconnection. For details, see Private Network Interconnection.
Note:
Lighthouse only supports association with CCNs under the same account. Lighthouse instances across different accounts cannot interconnect.

Note:

Tencent Cloud CCN offers three service levels: Platinum, Gold, and Silver.
The service level of data transfer in the same region is gold, which cannot be modified.
For cross-region interconnection, three service levels are provided: Platinum, Gold, and Silver. When creating a CCN, users can select a service level.
Different service levels incur different fees. You can select a level based on your business needs. For details, see Billing Overview.

Note:

1. Check whether the CCN route table is valid. Follow the steps below to perform the check:
1.1 On the "Private Network Interconnection" page, click the "CCN ID" in the region card to go to the CCN details page.
1.2 On the CCN details page, select the Route Table tab.
1.3 Ensure that the newly added route entry is "Valid". If a CIDR conflict exists, the route entry may be invalid.
Note:
To use invalid routes, see Disable Route and Enable Route. For conflict rules and restrictions, see Use Limits.
2. After logging in to the Lighthouse instance, if you repeatedly fail to log in to the cloud database via command, check whether the account and password you use for database login are incorrect.
In the command line: `mysql -h <private network ip address> -u <username, default root> -P <port number, default 3306> -p`. The account and password used for login must be correctly matched. If you log in with a non-root account, you must enter the password corresponding to that non-root account. When the password is entered on the Lighthouse page, the characters are not displayed as you type. You must enter the password correctly in one go and press Enter. If you forget the password, you can reset the password and try again.
3. Check whether any instance issues exist.
If the disk of a MySQL instance is full, it may affect database connections. It is recommended to scale out the disk. For the operation, see Adjusting Database Instance Specifications.
When the error message "ERROR 1040(00000):Too many connections" appears, it indicates that the current maximum number of connections for the cloud database instance has exceeded the limit. Common causes and solutions:
i. If there are many sleep threads, it is recommended to lower the wait_timeout and interactive_timeout parameter values in the console. For the operation, see Setting Instance Parameters.
ii. If there are few sleep threads and no slow query backlog, it is recommended to increase the max_connections parameter value in the console. For the operation, see Setting Instance Parameters.
Check whether the MySQL instance is in the "primary/secondary switching" state. If the MySQL instance is undergoing primary/secondary switching when you attempt to connect, the connection will fail. Please wait until the primary/secondary switching is complete, and then reconnect via command.

Help and Support

Was this page helpful?

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

Feedback