TencentDB for MySQL can be connected to in the following two methods:
Private network connection: a CVM instance can be used to connect to the private network address of a TencentDB instance. This method relies on the high-speed private network of Tencent Cloud and features low delay.
Note:
CVM and TencentDB instances in different VPCs (under the same or different accounts in the same or different regions) can be interconnected over private network through Cloud Connect Network.
Public network connection: if you cannot access the private network, you can connect to your TencentDB for MySQL instance at its public network address. The public network address needs to be manually enabled. It can be viewed on the instance details page in the TencentDB for MySQL Console and can be disabled if no longer needed.
The following describes how to log in to a TencentDB for MySQL instance from Windows and Linux CVM instance over the private and public networks.
Note:
We recommend you download MySQL Workbench. Visit https://dev.mysql.com/downloads/workbench/ and download an appropriate installer based on your 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.
root
by default. For public network connection, we recommend you create a separate account for easier connection control.Username
. If you forgot the password, reset it as instructed in Resetting Password.Log in to a Linux CVM instance. For more information, please see Configuring Linux CVM.
Taking a CVM instance on CentOS 7.2 (64-bit) as an example, run the following command to install the MySQL client:
yum install mysql
If Complete!
is displayed, the MySQL client is installed successfully.
Perform the corresponding operation based on the connection method:
Private network connection:
mysql -h hostname -u username -p
root
.root
account of the TencentDB for MySQL instance after Enter password:
is prompted. If you forgot the password, please reset it as instructed in Resetting Password.MySQL [(none)]>
is displayed, you have logged in to MySQL successfully.Public network connection:
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.Under the MySQL \[(none)]>
prompt, you can send an SQL statement to the MySQL server for execution. For specific command lines, please see mysql Client Commands.
Below takes show databases;
as an example:
Note:
If the basic info section contains the public network address and port, it indicates that the public network address has been enabled.
Note:
The public network connection can be disabled using the switch. When it is enabled again, the public network address corresponding to the domain name remains the same.
We recommend you troubleshoot and locate network connectivity problems quickly with the telnet
command. For more information, please see telnet Command.
If the verification with telnet found that the network access of the TencentDB instance was good, but an error was reported when you tried to log in to it on the command line in the CVM instance, please see Connection.
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 Troubleshooting Connection Errors according to the check report.
Was this page helpful?