tencent cloud

Feedback

FAQs on Connectivity

Last updated: 2023-12-27 10:11:11
    This document outlines common issues associated with connecting to a TencentDB for MySQL instance through different connection methods including private network connection, public network connection, and CCN connection.

    Common Issues

    Regardless of which method is used to connect to the database, the following issues are likely to occur. If the connection fails, please first check and locate the fault based on the following instructions during self-check.
    Account Password Issue
    Upon repeated failures to log into TencentDB using commands after logging into CVM, please check whether the account or password used to log into the database is correct.
    In the command mysql -h <public/private IP address> -u <username, default is root> -P <public/private port number> -p, the account and password used to log in must be correctly paired. If you are using a non-root account to log in, you should also enter the corresponding password for the non-root account. When entering the password on the CVM interface, the password will not be displayed as you type. It should be entered correctly in one go and confirmed by pressing the Enter key. If you forget the password, you can reset the password and then try again.
    MySQL Instance Issue
    If the MySQL instance itself is faulty, the connection may fail. You can check for the following issues related to the instance.
    If the MySQL instance disk is full, it may affect database connectivity. It's recommended to expand the disk capacity. For the procedure, please refer to Adjusting Database Instance Specification.
    When the error message "ERROR 1040(00000): Too many connections" is displayed, it indicates that the maximum number of connections for the current CDB instance has been reached. Common causes and solutions are as follows: i. If there are too many sleep threads, it's advised to decrease the values of the wait_timeout and interactive_timeout parameters via the console. For details, please refer to Setting Instance Parameters. ii. If there are few sleep threads and no slow query accumulation, it's suggested to increase the value of the max_connections parameter via the console. For details, please refer to Setting Instance Parameters.
    Check whether the MySQL instance is in a "master-slave switch state", as connection attempts will fail if the MySQL instance is in the middle of a master-slave switch. After the switch has completed, connect using the command again.

    FAQs on Private Network Connection

    Are there any charges for private network connection?

    Private network connections are currently free of charge.

    Can the private network port be modified?

    Yes, it can be modified. You can log in to the TencentDB for MySQL console, navigate to the details page of the target instance, and click the edit icon following the private network address to make changes.
    

    How can I check private network connection errors?

    The potential causes for the failure to connect to a database via a private network address could be typically related to the type of CVM, account password, port, DFW, the network, and instance issues. The following provides self-check methods in various scenarios. For more self-check procedures, please refer to Private Network Connection Failure.
    1. Check whether the server you are using is a CVM.
    For private network connections, the server in use needs to be a Tencent CVM. If you are using a Lighthouse Server or another non-Tencent server, connecting through a private network address is not currently supported. You can refer to Customizing a Linux CVM to recreate a CVM and then connect to the database using the private network address.
    2. After logging into the CVM instance, if you repeatedly fail to log in to the cloud database via command, it's suggested to check if there are any errors in the database login account and password.
    When entering the command: mysql -h <private IP address> -u <username, default is root> -P <port number, default is 3306> -p, the account username and password used for login must be paired correctly. If you are using a non-root account to log in, you need to enter the password of the corresponding non-root account. The password will not be displayed as you input it on the CVM interface; it needs to be entered correctly in one go and confirmed with the Enter key. If you have forgotten the password, you can reset the password and then try again.
    3. Review whether the DFW configuration is correct and whether the IP is restricted.
    Configure outbound rules in the CVM DFW.When the target configuration of the outbound rule is not set to 0.0.0.0/0 and the protocol port is not set to ALL, the private IP and port of TencentDB for MySQL needs to be added to the outbound rule.
    Configure inbound rules in the TencentDB for MySQL DFW. When the source configuration of the inbound rule is not set to 0.0.0.0/0 and the protocol ports are not set to ALL, the IP and port of the CVM instance should be added to the inbound rule.
    For instructions, please see the Security Group Configuration Problem Resolution.
    4. Evaluate if the issue is network-related.
    The CVM and MySQL must be in the same region and VPC network. Go to the CVM Console and TencentDB Console to verify. If they are not in the same VPC network, use Switch Networks to change the network of the MySQL instance to be the same as the CVM. If the CVM and MySQL are confirmed to be in the same region and VPC network and there are still reported network errors, please check whether there are restrictions on your local network.
    5. Check whether there is an instance-related issue.
    If the MySQL instance disk is full, it may affect database connectivity. It's recommended to expand the disk capacity. For the procedure, please refer to Adjusting Database Instance Specification.
    When the error message "ERROR 1040(00000): Too many connections" is displayed, it indicates that the maximum number of connections for the current CDB instance has been reached. Common causes and solutions are as follows: i. If there are too many sleep threads, it's advised to decrease the values of the wait_timeout and interactive_timeout parameters via the console. For details, please refer to Setting Instance Parameters. ii. If there are few sleep threads and no slow query accumulation, it's suggested to increase the value of the max_connections parameter via the console. For details, please refer to Setting Instance Parameters.
    Check whether the MySQL instance is in a "master-slave switch state", as connection attempts will fail if the MySQL instance is in the middle of a master-slave switch. After the switch has completed, connect using the command again.

    FAQs on Public Network Connection

    Do I need to pay for public network connection?

    Public network connection is currently free of charge.

    Why is it necessary to release the MySQL private port for a public network connection?

    When the MySQL instance enables a public network address, Tencent Cloud's backend cluster is used to connect to the database's private network port. The port mapping and forwarding are performed to achieve public network access. Therefore, after enabling the public network address, the MySQL private port needs to be released in the security group to the backend cluster connections.

    Can the public network port be modified?

    No. Modifications are not supported.

    Is the public network connection secure?

    Enabling public network access will expose your database services and be invaded or attacked. It is generally advised to use the private network for database connection.Public network connection is primarily used for development or auxiliary database management and is not recommended for formal business access. Because potential uncontrollable factors may render the connection unavailable, including DDoS attacks and unexpected high-volume traffic.

    After enabling a public network address, how can I only allow connections to specific IPs and forbid access from all other IPs?

    By imposing restrictions on host permissions, you can modify the authorized host addresses for your database account through the TencentDB console, thus limiting database access. For more information, please refer to Modifying Host Addresses with Access Permissions.
    Alternatively, you can use a public CLB for traffic forwarding to enable public network access. Access restrictions can be imposed by using security group policies in CLB. For more information, please refer to Enabling Public Network Access Through CLB.

    Why can't I enable public network access?

    Public network access can be enabled for main instances deployed in Guangzhou, Shanghai, Beijing, Chengdu, Chongqing, Nanjing, Hong Kong (China), Singapore, Seoul, Tokyo, Silicon Valley, Virginia, and Frankfurt. For the latest information about the regions where public network access can be enabled for read-only instances, please refer to the console. If your instance is deployed in a region where public network access is not supported, public network access cannot be enabled.
    

    How can I troubleshoot public network connection errors by myself?

    Possible causes for failing to connect to a database through a public network address often involve scenarios related to account passwords, ports, security group, networks, and instance issues. The following content provides methods for self-check in various scenarios.
    1. After logging into the CVM instance, if you repeatedly fail to log in to the cloud database via command, it's suggested to check if there are any errors in the database login account and password.
    In the command line: mysql -h <public IP address> -u <username, default: root> -P <public port number> -p, the account and password used for login must be paired correctly. If you are logging in with a non-root account, you also need to input the password for the corresponding non-root account. The password will not be displayed as you type it in the CVM interface. You must enter it correctly in one go and press the Enter key to confirm. If you forget your password, you can reset your password and try again.
    2. Review whether the DFW configuration is correct and whether the IP is restricted.
    Configure outbound rules in the CVM DFW. When the outbound rule is not set to 0.0.0.0/0 and the protocol port is not set to ALL in the target configuration of outbound rules, you need to add the external IP and port of MySQL to the outbound rules.
    Configure inbound rules in the MySQL security group. If the source end in inbound rules is not set to 0.0.0.0/0 and the protocol port is not set to ALL, you need to release the internal port for the MySQL instance in the inbound rules. The default port is 3306.
    For instructions, please see the Security Group Configuration Problem Resolution.
    3. Evaluate if the issue is network-related.
    Connecting to the database over the public internet could fail due to various reasons such as unstable network, local network restrictions, or VPCs bound with ACL policies. In this case, switch your local network, remove relevant restrictions, and try again. We recommend using private network to connect to the database for a more reliable and low-latency experience.
    4. Check whether there is an instance-related issue.
    If the MySQL instance disk is full, it may affect database connectivity. It's recommended to expand the disk capacity. For the procedure, please refer to Adjusting Database Instance Specification.
    When the error message "ERROR 1040(00000): Too many connections" is displayed, it indicates that the maximum number of connections for the current CDB instance has been reached. Common causes and solutions are as follows: i. If there are too many sleep threads, it's advised to decrease the values of the wait_timeout and interactive_timeout parameters via the console. For details, please refer to Setting Instance Parameters. ii. If there are few sleep threads and no slow query accumulation, it's suggested to increase the value of the max_connections parameter via the console. For details, please refer to Setting Instance Parameters.
    Check whether the MySQL instance is in a "master-slave switch state", as connection attempts will fail if the MySQL instance is in the middle of a master-slave switch. After the switch has completed, connect using the command again.

    FAQs on CCN Connection

    Do I have to pay for CCN connections?

    Yes. You should pay for CCN connections. For details, see CCN Billing Details.

    Under what circumstances should a CCN be used to connect to a MySQL?

    1. CCN can be used to connect to the database when the CVM and MySQL instances are in different VPCs, no matter under the same or different accounts, or in the same or different regions.
    2. If you have purchased a Lighthouse server, you can connect to the database only through CCN.

    How can private network interconnection be achieved when using Lighthouse instances?

    Lighthouse uses the VPC automatically assigned by Tencent Cloud for network isolation. By default, the private network does not interconnect with other Tencent Cloud resources in VPCs such as CVM and TencentDB. The interconnection can be implemented by associating with a CCN. For more information, please refer to Private Network Interconnection.
    Note:
    Lighthouse only supports associating with CCNs under the same account and does not support the association across different accounts.

    What is the service level of CCN?

    Tencent Cloud CCN offers three levels of availability: Platinum, Gold, and Silver.
    The service level for all intra-region instances is Gold, and cannot be modified.
    During cross-region intercommunication, three service levels—Platinum, Gold, and Silver—are available for you to choose from upon CCN creation. The costs differ with the service level. You can select the most suitable one based on your business requirements. For more information, see Pricing.

    How do I troubleshoot a CCN connection error myself?

    1. Check whether the route table for the CCN is valid by following the following steps:
    1.1 On the "Private Network Interconnection" page, click the "CCN ID" on the regional card to navigate to the details page of that CCN.
    1.2 On the CCN details page, select the Route Table tab.
    1.3 You need to ensure that the newly added route is marked as "Valid". If there are CIDR conflicts, the route could be invalid.
    Note:
    If you need to utilize an invalid route, see Disabling a Route and Enabling a Route. For Conflict rules and restrictions, see Route Limits.
    2. Upon logging in to Lighthouse, if you repeatedly fail to log into the cloud database via the command, you may need to check whether the username or password used for database access are correct.
    In the command line: mysql -h <private ip address> -u <username, default root> -P <port number, default 3306> -p, the account and password must be paired correctly. If you're logging in with a non-root account, then the password should also correspond to the non-root account. When entering your password in the Lighthouse interface, the password will not be displayed as you type. Enter it correctly all at once and press Enter. If you forget the password, you may reset the password and try again.
    3. Check whether there is an instance-related issue.
    If the MySQL instance disk is full, it may affect database connectivity. It's recommended to expand the disk capacity. For the procedure, please refer to Adjusting Database Instance Specification.
    When the error message "ERROR 1040(00000): Too many connections" is displayed, it indicates that the maximum number of connections for the current CDB instance has been reached. Common causes and solutions are as follows: i. If there are too many sleep threads, it's advised to decrease the values of the wait_timeout and interactive_timeout parameters via the console. For details, please refer to Setting Instance Parameters. ii. If there are few sleep threads and no slow query accumulation, it's suggested to increase the value of the max_connections parameter via the console. For details, please refer to Setting Instance Parameters.
    Check whether the MySQL instance is in a "master-slave switch state", as connection attempts will fail if the MySQL instance is in the middle of a master-slave switch. After the switch has completed, connect using the command again.
    
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support