Skip to main content

TDSQL Database Integration Guide

HAP Server uses MySQL as its default relational database. Since v6.2.0, it also supports Tencent Cloud TDSQL. For environments with domestic technology requirements, you can use this database instead of MySQL.

Follow these integration steps:

  1. Provision TDSQL with the InnoDB engine (primary-standby mode, MySQL 8.0 kernel) or the TDStore engine (cluster edition, MySQL 8.0 compatible).

  2. Open Management > Account Management > Create Account in the instance, create the account, and then adjust its permissions.

  3. Download the HAP database initialization scripts.

  4. Initialize the data

    Import SQL files through the TDSQL management console or use another MySQL client such as DBeaver or mysql. The following example uses mysql:

    Run the initialization scripts (adjust the IP address, port, username, password and SQL file paths for your environment).

    mysql -h 127.0.0.1 -P 3306 -uroot -p****** < /usr/local/init_tdsql/1_MDProject.sql
    mysql -h 127.0.0.1 -P 3306 -uroot -p****** < /usr/local/init_tdsql/2_MDStructure.sql
    mysql -h 127.0.0.1 -P 3306 -uroot -p****** < /usr/local/init_tdsql/3_MDApplication.sql
    mysql -h 127.0.0.1 -P 3306 -uroot -p****** < /usr/local/init_tdsql/4_MDCalendar.sql
    mysql -h 127.0.0.1 -P 3306 -uroot -p****** < /usr/local/init_tdsql/5_MDLog.sql
    mysql -h 127.0.0.1 -P 3306 -uroot -p****** < /usr/local/init_tdsql/6_Data_MDProject.sql
    mysql -h 127.0.0.1 -P 3306 -uroot -p****** < /usr/local/init_tdsql/7_Data_MDApplication.sql
  5. Initialize HAP services

    Before initializing services, add the following environment variables (replace connection parameter values with actual values):

    ENV_RDB_TYPE: "8"
    ENV_RDB_URI_MDPROJECT: "Server=127.0.0.1;Port=3306;Database=MDProject;uid=root;password=******;"
    ENV_RDB_URI_MDLOG: "Server=127.0.0.1;Port=3306;Database=MDLog;uid=root;password=******;"
    ENV_RDB_URI_MDSTRUCTURE: "Server=127.0.0.1;Port=3306;Database=MDStructure;uid=root;password=******;"
    ENV_RDB_URI_MDCALENDAR: "Server=127.0.0.1;Port=3306;Database=MDCalendar;uid=root;password=******;"
    ENV_RDB_URI_MDAPPLICATION: "Server=127.0.0.1;Port=3306;Database=MDApplication;uid=root;password=******;"
    ENV_STANDALONE_DISABLE_SERVICES: "mysql"
  6. Complete the remaining system initialization steps.