This document describes how to connect to an initialized TencentDB for MySQL instance over the private or public network.
Note:To connect to a TencentDB for MySQL instance, no matter whether over the private or public network, you must open its port. You can log in to the TencentDB for MySQL console, click an instance ID in the instance list, and view its port number on the instance details page.
- TencentDB for MySQL uses private network port 3306 by default and supports customizing the port. If the default port is changed, the new port should be opened in the security group.
- The TencentDB for MySQL public port is automatically assigned by the system and cannot be customized. After the public network access is enabled, it will be controlled by the ACL of the security group. When configuring the security policy, you need to open the private port 3306.
- The security group rules displayed on the Security Group page in the TencentDB for MySQL console take effect for private and public (if enabled) network addresses of the TencentDB for MySQL instance.
TencentDB for MySQL can be connected in the following methods:
Note:CVM and TencentDB instances in different VPCs (under the same or different accounts in the same or different regions) can be interconnected over the private network through Cloud Connect Network.
The following describes how to log in to a TencentDB for MySQL instance from Windows and Linux CVM instances over the private and public networks.
Note:We recommend you download MySQL Workbench. Click here and download an installer based on your operating system.
Note:
- Microsoft .NET Framework 4.5 and Visual C++ Redistributable for Visual Studio 2015 are required for the installation.
- You can click Download Prerequisites in the MySQL Workbench installation wizard to enter the corresponding page to download and install them. Then, install MySQL Workbench.
Username
. If you forgot the password, reset it as instructed in Resetting Password.yum install mysql
If Complete!
is displayed, the MySQL client is installed successfully.
3. Perform the corresponding operation based on the connection method:
Private network connection:
mysql -h hostname -u username -p
Note:
- The default port number of MySQL is 3306.
- If the port number is 3306, you only need to replace
hostname
with the IP address. For example, if the private network address is 10.16.0.11:3306, sethostname
to10.16.0.11
.- If the port number is not 3306, you need to specify the port in the connection command in the format of
mysql -h hostname -P port -u username -p
, such asmysql -h 10.16.0.11 -P 5308 -u username -p
.
root
.root
account of the TencentDB for MySQL instance after Enter password:
is prompted. If you forgot the password, you can reset it as instructed in Resetting Password.MySQL [(none)]>
is displayed, you have logged in to MySQL successfully.mysql -h hostname -P port -u username -p
Enter password:
is prompted. If you forgot the password, reset it as instructed in Resetting Password.hostname
is 59281c4exxx.myqcloud.com and public network port is 15311.MySQL [(none)]>
prompt, you can send a SQL statement to the MySQL server for execution. For specific command lines, see mysql Client Commands.show databases;
as an example:If you encounter connection errors, we recommend you use One-Click Connectivity Checker to troubleshoot the problem first and then find the corresponding solution in Instance Connection Failure according to the check report.
We recommend that you troubleshoot and locate network connectivity problems quickly with the telnet
command. For more information, see Prohibition of Ping Command.
If the verification with telnet
found that the network access of the TencentDB instance was normal, but an error was reported when you tried to log in to it via the command line in the CVM instance, see Connection.
Note:If the Basic Info section displays the public IP and port, the public network address has been enabled.
Note:
- After the public network address is enabled successfully, it can be viewed in the basic information.
- The public network access can be disabled by using the switch. When it is enabled again, the public network address corresponding to the domain name remains the same.
Was this page helpful?