edit-icon download-icon

Connect to DRDS

Last Updated: Apr 02, 2018

After creating the DRDS instance, database, and table on the console, connect to DRDS to perform futher operations.

Procedure

  1. On the Basic Information page of a database, find Command Line URL, which is the DRDS connection information, including the IP address or domain name, port number, user name, and password

  2. Connect to the DRDS instance through a third-party tool or program code.

    • Third-party tool

      DRDS complies with the MySQL protocol; therefore, you can connect to DRDS using a third-party tool.

      1. //Run the connection command
      2. mysql -h${DRDS_IP_ADDRESS} -P${DRDS_PORT} -u${user} -p${password} -D${DRDS_DBNAME}

      Note:DRDS is fully compatible with the official MySQL command-line clients of version 5.1 or later. DRDS does not support the commands of earlier versions (such as 3.x and 4.x) or infrequently used commands. Therefore, DRDS only guarantees that basic database operations (DDL operations and add/delete/modify/query data) can be performed on a third-party GUI client.

    • Program code

      You can connect to the DRDS instance through the MySQL driver or a third-party program compliant with the MySQL interaction protocol.

Client tools supported by DRDS

  • (Recommended) MySQL Command-Line Tool
  • (Recommended) MySQL Workbench
  • SQLyog
  • Sequel Pro
  • Navicat for MySQL

Program driver supported by DRDS

  • JDBC Driver for MySQL (Connector/J)

    1. //JDBC
    2. Class.forName("com.mysql.jdbc.Driver");
    3. Connection conn = DriverManager.getConnection("jdbc:mysql://drdsxxxxx.drds.aliyuncs.com:3306/doc_test","doc_test","doc_test_password");
    4. //...
    5. conn.close();
    • Python Driver for MySQL (Connector/Python)
    • C++ Driver for MySQL (Connector/C++)
    • C Driver for MySQL (Connector/C)
    • ADO.NET Driver for MySQL (Connector/NET)
    • ODBC Driver for MySQL (Connector/ODBC)
    • PHP Drivers for MySQL (mysqli, ext/mysqli, PDO_MYSQL, PHP_MYSQLND)
    • Perl Driver for MySQL (DBD::mysql)
    • Ruby Driver for MySQL (ruby-mysql)

Connection string configuration example**

  • We recommend that you use the Druid connection pool to connect to DRDS. For more information on Druid, see Druid Github.

  • Configuration example:

    1. <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
    2. <property name="url" value="jdbc:mysql://drdsxxxxx.drds.aliyuncs.com:3306/doc_test" />
    3. <property name="username" value="doc_test" />
    4. <property name="password" value="doc_test_password" />
    5. <property name="filters" value="stat" />
    6. <property name="maxActive" value="100" />
    7. <property name="initialSize" value="20" />
    8. <property name="maxWait" value="60000" />
    9. <property name="minIdle" value="1" />
    10. <property name="timeBetweenEvictionRunsMillis" value="60000" />
    11. <property name="minEvictableIdleTimeMillis" value="300000" />
    12. <property name="testWhileIdle" value="true" />
    13. <property name="testOnBorrow" value="false" />
    14. <property name="testOnReturn" value="false" />
    15. <property name="poolPreparedStatements" value="true" />
    16. <property name="maxOpenPreparedStatements" value="20" />
    17. <property name="asyncInit" value="true" />
    18. </bean>
Thank you! We've received your feedback.