tencent cloud

TDSQL for MySQL

Announcements
Alarm Upgrade
Product Introduction
Overview
Strengths
Use Cases
Regions and AZs
InnoDB engine
Purchase Guide
Billing Overview (InnoDB)
Product Pricing (InnoDB)
Purchase and Upgrade
Refund
Payment Overdue
Backup Space Billing
Getting Started
InnoDB Engine
Operation Guide(InnoDB)
Instance Management
Disaster Recovery Read-Only Instance
Changing Networks
Account Management
Security Management
Slow Query Analysis
Backup and Rollback
Data Migration
Database Audit
Practical Tutorial
Import from Standalone Instance to TDSQL Instance
Import Between TDSQL Instances
Selection of TDSQL Instance and Shard Configuration
Security White Paper
Platform Security Design
Tenant Security Features
Development Guide
InnoDB
API Documentation
History
Introduction
API Category
Security Group APIs
Other APIs
Making API Requests
TDSQL APIs
Data Types
Error Codes
FAQs
InnoDB
General References
Performance Comparison Data for Strong Sync
Glossary
Contact Us

Connecting Database

PDF
フォーカスモード
フォントサイズ
最終更新日: 2024-01-06 17:34:55

Connecting with Client

TDSQL for MySQL supports a connection method compatible with MySQL. It can be connected using the IP address, port number, username, and password, as shown below:
mysql -hxxx.xxx.xxx.xxx -Pxxxx -uxxx -pxxx -c
Note:
TDSQL for MySQL does not support clients earlier than version 4.0 and compression protocols. We recommend that you add the -c option when using the client, so that you can use advanced features.

Connecting with PHP MySQLi

To connect to TDSQL for MySQL in PHP, you need to enable the MySQLi extension. A demo is as follows:
header("Content-Type:text/html;charset=utf-8");
$host="10.10.10.10"; //Instance proxy_host_ip
$user="test"; //Instance user
$pwd="test"; //Instance password
$db="aaa"; //Database name
$port="15002"; //proxy_host port number
$sqltool=new MySQLli($host,$user,$pwd,$db,$port);
//Other necessary code
$sqltool->close();
echo "ok"."\\n";

Connecting with JDBC

You can run the following code to connect to TDSQL for MySQL with JDBC:
private final String USERNAME = "test";
private final String PASSWORD = "123456";
private final String DRIVER = "com.mysql.jdbc.Driver";
private final String URL = "jdbc:mysql://10.10.10.10:3306?userunicode=true&characterEncoding=utf8mb4";
private Connection connection;
private PreparedStatement pstmt;
private ResultSet resultSet;

Other Connection Methods

TDSQL for MySQL supports other connection methods compatible with MySQL, such as Navicat and ODBC.

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック