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:
-
Provision TDSQL with the InnoDB engine (primary-standby mode, MySQL 8.0 kernel) or the TDStore engine (cluster edition, MySQL 8.0 compatible).
-
Open Management > Account Management > Create Account in the instance, create the account, and then adjust its permissions.
-
Download the HAP database initialization scripts.
-
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.sqlmysql -h 127.0.0.1 -P 3306 -uroot -p****** < /usr/local/init_tdsql/2_MDStructure.sqlmysql -h 127.0.0.1 -P 3306 -uroot -p****** < /usr/local/init_tdsql/3_MDApplication.sqlmysql -h 127.0.0.1 -P 3306 -uroot -p****** < /usr/local/init_tdsql/4_MDCalendar.sqlmysql -h 127.0.0.1 -P 3306 -uroot -p****** < /usr/local/init_tdsql/5_MDLog.sqlmysql -h 127.0.0.1 -P 3306 -uroot -p****** < /usr/local/init_tdsql/6_Data_MDProject.sqlmysql -h 127.0.0.1 -P 3306 -uroot -p****** < /usr/local/init_tdsql/7_Data_MDApplication.sql -
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" -
Complete the remaining system initialization steps.