Connecting Database

Last updated: 2020-10-30 11:02:50

    Connecting with Client

    TDSQL supports a connection method compatible with MySQL. It can be connected using the IP address, port number, username, and password, as shown below:

    mysql -Pxxxx -uxxx -pxxx -c


    TDSQL 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 in PHP, you need to enable the MySQLi extension. A demo is as follows:

    $host="";  //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
    echo "ok"."\n";

    Connecting with JDBC

    You can run the following code to connect to TDSQL 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://";  
    private Connection connection;  
    private PreparedStatement pstmt;  
    private ResultSet resultSet;  

    Other Connection Methods

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

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback