Problem Description
Failed to connect to a TDSQL-C for MySQL instance via a private network address from Cloud Virtual Machine (CVM).
Note:
There are various ways to connect to TDSQL-C for MySQL, such as login through the Database Management Center (DMC) console, private network connections, public network connections, and Cloud Connect Network (CCN) connections. Different connection methods require different conditions. For example, if you need to connect to TDSQL-C for MySQL via a public network address, but you enter a private network address in the command line, the connection will fail. Similarly, if you have purchased Lighthouse but have not connected to a network through CCN, the connection will also fail when you directly use a command to connect to TDSQL-C for MySQL. Therefore, when the connection fails, it is recommended to first refer to the connection methods and application scenarios in Connecting to Cluster > Overview to check whether the conditions are met. Possible Causes
|
| The password is incorrect. |
| CVM and TDSQL-C for MySQL are in the same region but belong to different Virtual Private Cloud (VPC) networks. |
| CVM and TDSQL-C for MySQL are not in the same region and belong to different VPC networks. |
| The CVM security group configuration is incorrect. |
| The TDSQL-C for MySQL security group configuration is incorrect. |
| The database account restricts access of specific host addresses. |
| The connection command is incorrect. |
| The IP address and port in the command line or configuration file are incorrect. |
| The TDSQL-C for MySQL instance's storage space is full, the maximum number of connections has been reached, there is an issue with the timeout parameter settings, the instance is in the "availability zone switching" state, and other issues. |
TDSQL-C for MySQL instance running status | The TDSQL-C for MySQL instance is isolated. You can use the recycle bin to restore it. |
CVM instance status | The CVM instance is isolated or shut down. You can restore or start it in the console. |
Solutions
Password Issue: The Password Is Incorrect
Network Issue 1: CVM and TDSQL-C for MySQL Are in the Same Region but Belong to Different VPC Networks
By default, both CVM and TDSQL-C for MySQL use VPC networks, and they can communicate over the private network only if they are in the same VPC. If they are in the same region but different VPCs, you can switch the network of TDSQL-C for MySQL to the VPC where CVM resides, so that CVM can communicate with TDSQL-C for MySQL. For the procedure, refer to Changing Network. Network Issue 2: CVM and TDSQL-C for MySQL Are Not in the Same Region and Belong to Different VPC Networks
If CVM and TDSQL-C for MySQL are not in the same region and belong to different VPC networks, CVM cannot connect to TDSQL-C for MySQL over the private network. It is recommended to use a CVM instance that is in the same VPC as TDSQL-C for MySQL for connection. If there is no CVM instance in the same region as TDSQL-C for MySQL, you can create a CVM instance in the same region and VPC network as TDSQL-C for MySQL on the CVM purchase page. Security Group Configuration Issue 1: The CVM Security Group Configuration Is Incorrect
To connect CVM to TDSQL-C for MySQL, you need to configure outbound rules in the CVM security group. When the target configuration of the outbound rules is not 0.0.0.0/0 and the protocol port is not ALL, you should add the private IP address and port of TDSQL-C for MySQL to the outbound rules.
1. Log in to the Security Group console and click the security group name to enter the details page of the security group associated with CVM. 2. Select the Outbound Rules tab and click Add Rule.
Select MySQL (3306) for Type; enter the private IP address (range) of your TDSQL-C for MySQL for Target; select Allow for Policy.
Security Group Configuration Issue 2: The TDSQL-C for MySQL Security Group Configuration Is Incorrect
To allow the specified CVM to connect to TDSQL-C for MySQL, you need to configure inbound rules in the TDSQL-C for MySQL security group. When the source configuration of the inbound rules is not 0.0.0.0/0 and the protocol port is not ALL, you should add the IP address and port of the CVM to the inbound rules.
1. Log in to the Security Group console and click the security group name to enter the details page of the security group associated with TDSQL-C for MySQL. 2. Select the Inbound Rules tab and click Add Rule.
Fill in the IP address (range) you allow to connect and the port to be opened (private network port of TDSQL-C for MySQL) and choose to allow access.
Select MySQL (3306) for Type; enter the private IP address (range) of your CVM for Source; select Allow for Policy.
Issue with the Host Addresses Authorized to an Account: The Database Account Restricts Access of Specific Host Addresses
In addition to security group and subnet restrictions, a database account is also restricted by the TDSQL-C for MySQL account system. If the database account specifies a particular host address, other addresses cannot connect to TDSQL-C for MySQL.
You can modify the host address authorized to the database account via the TDSQL-C for MySQL console to restrict database access and enhance connection security.
1. Log in to the TDSQL-C for MySQL console and click the cluster ID in the cluster list to enter the cluster management page. 2. Select the Account Management tab, find the account for which you need to modify the host address, and choose More > Modify Host in the Operation column.
3. In the pop-up window, enter a new host address and click OK to modify the host address authorized to the account.
Note:
The host address can be an IP address or contains % (indicating no limit on the IP range). Multiple host addresses should be separated by delimiters, and the delimiters can be line breaks, spaces, and ; , |
.
Example 1: Entering % indicates no limit on the IP range, allowing clients from any IP address to use this account to connect to a database.
Example 2: Entering 10.5.10.% indicates that clients with IP addresses in the range of 10.5.10.% can use this account to connect to a database.
Connection Syntax Issue: The Connection Command Is Incorrect
Check whether the connection command is incorrect. Refer to the standard private network connection command:
mysql -h <Private IP address> -u <Username, default root> -P <Port number, default 3306> -p
<Private IP address>: Replace it with the private IP address of the target TDSQL-C for MySQL database instance, which can be found on the cluster details page in the TDSQL-C for MySQL console. Note:
For example, if the private IP address is 10.16.0.11:3306, replace the <private IP address> with 10.16.0.11.
<Username, default root>: Replace it with the account name of the target TDSQL-C for MySQL database instance. The default account name is root.
<Port number, default 3306>: Replace it with the private network port number of the target TDSQL-C for MySQL database instance. The default value is 3306. If it has been changed, use the new port number.
Issue with IP Addresses and Ports: The IP Address and Port in the Command Line or Configuration File Are Incorrect
When connecting to a database via commands, check whether the instance's private IP address and port number are correct, which can be found on the cluster details page in the TDSQL-C for MySQL console. TDSQL-C for MySQL Instance Issue: The TDSQL-C for MySQL Instance's Storage Space Is Full, the Maximum Number of Connections Has Been Reached, There Is an Issue with the Timeout Parameter Settings, and Other Issues
If the storage space of a TDSQL-C for MySQL instance is full, it may affect the connection to a database. It is recommended to expand the storage space. For the procedure, refer to Adjusting Storage Space. When the message "ERROR 1040(00000): Too many connections" appears, it means the current number of connections of a cloud database instance has exceeded the limit. Common causes and solutions are as follows:
i. There are many sleep threads. It is recommended to reduce the values of the wait_timeout and interactive_timeout parameters in the console. For the procedure, refer to Setting Instance Parameters.
ii. There are few sleep threads and no slow query accumulation. It is recommended to increase the value of the max_connections parameter in the console. For the procedure, refer to Setting Instance Parameters. Check whether the instance is in the "availability zone switching" state. If the TDSQL-C for MySQL instance is in the "availability zone switching" state, the connection will fail. Wait for the switching to complete before reconnecting via commands.
Was this page helpful?