Connection Methods
You can connect to TDSQL-C for MySQL in the following ways:
- Private network connection: A CVM instance can be used to connect to the private network address of a TDSQL-C for MySQL instance. This method utilizes the high-speed private network of Tencent Cloud and features low delay.
- The CVM instance and the database must be under the same account and in the same VPC in the same region.
- The private network address is provided by the system by default and can be viewed in the cluster list or on the cluster details page in the console.
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.
- Public network connection: You can connect to your TDSQL-C for MySQL cluster 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 console and can be disabled if no longer needed.
- Enabling the public network address will expose your database services to the public network, which may lead to database intrusions or attacks. We recommend you use the private network to connect to the database.
- Public network access to TencentDB is suitable for development or auxiliary database management but not for actual business access, because uncontrollable factors may cause public network access to be unavailable, such as DDoS attacks and sudden surges in access traffic.
- DMC connection: You can access TDSQL-C for MySQL through Database Management Console (DMC).
Connection to TDSQL-C for MySQL over Private or Public Network
Connecting from Windows CVM instance
- Log in to a Windows CVM instance. For more information, see Customizing Windows CVM Configurations.
- Download a standard SQL client.
Note:
We recommend you download MySQL Workbench. Click here and download an installer based on your operating system.
- Login, Sign Up, and No thanks, just start my download. will appear on the page. Select No thanks, just start my download. to download quickly.
- Install MySQL Workbench on this CVM instance.
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.
- Open MySQL Workbench, select Database > Connect to Database, enter the private (or public) network address, username, and password of your MySQL instance and click OK to log in.
- Hostname: Enter the private (or public) network address of the target database, which can be viewed on the cluster details page in the console. For public network address, check whether it has been enabled as instructed in Enabling Public Network Address.
- Port: Private (or public) network port.
- Username: The default value is
root
.
- Password: The password corresponding to the username. If you forgot the password, reset it in the console.
- After successful login, the following page will appear, where you can view the modes and objects of the database, create tables, and perform operations such as data insertion and query.
Connecting from Linux CVM instance
- Log in to the Linux CVM instance. For more information, see Customizing Linux CVM Configurations.
- 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.
3. Perform the corresponding operation based on the connection method:
- Under the
MySQL [(none)]>
prompt, you can send an SQL statement to the TDSQL-C for MySQL server for execution. For specific command lines, see mysql Client Commands.
Below takes show databases;
as an example:
Connection Through DMC
- Log in to the console and click Log In in the Operation column in the cluster list.
- On the login page of DMC, enter "root" as the account and the password configured for the root account during cluster creation and click Log In.
Note:
DMC enables you to easily access instances, manipulate tables and databases, manage instance sessions, and monitor InnoDB lock waits, SQL window, etc. in real time.
Note:
To connect over the public network, you need to enable the public network address of your database first.
- Log in to the console and click a cluster ID in the cluster list to enter the cluster details page.
- On the cluster details page, click Enable after the public network addresses.
- In the pop-up window, click OK.
Note:
- Once enabled successfully, the public network address can be viewed in the connection information.
- The public network access can be disabled by using the switch. When it is enabled again, the public IP corresponding to the domain name remains the same.
- To access the public network, you need to enable and configure a security group policy and open the default (3306) or modified private network access port.
Was this page helpful?