AnalyticDB for MySQL

Updated at:

This topic describes the connection properties of the analyticdb_for_mysql data source type in DataWorks. Use these properties to configure data source connections in either instance mode or connection string mode.

Property definition

  • Data source type: analyticdb_for_mysql

  • Supported configuration modes (ConnectionPropertiesMode):

    • Instance mode (InstanceMode): connect using an AnalyticDB for MySQL instance ID. Supports both current-account and cross-account scenarios.

    • Connection string mode (UrlMode): connect using a host and port directly.

Current-account instance mode

Use this mode when the AnalyticDB for MySQL instance is in the same Alibaba Cloud account as your DataWorks workspace.

Parameter Type Required Example Description
regionId String Yes cn-shanghai The region where the AnalyticDB for MySQL instance resides.
instanceId String Yes am-wz90k6goz2i63d8m1 The ID of the AnalyticDB for MySQL instance.
database String Yes database_demo The name of the AnalyticDB for MySQL database.
username String Yes xxxxx The username for accessing the database.
password String Yes xxxxx The password for accessing the database.
envType String Yes Dev The environment type. Valid values: Dev (development environment), Prod (production environment).

Cross-account instance mode

Use this mode when the AnalyticDB for MySQL instance belongs to a different Alibaba Cloud account. In addition to the parameters in current-account instance mode, specify the following cross-account parameters.

Parameter Type Required Example Description
regionId String Yes cn-shanghai The region where the AnalyticDB for MySQL instance resides.
instanceId String Yes am-wz90k6goz2i63d8m1 The ID of the AnalyticDB for MySQL instance.
database String Yes database_demo The name of the AnalyticDB for MySQL database.
username String Yes xxxxx The username for accessing the database.
password String Yes xxxxx The password for accessing the database.
crossAccountOwnerId String Yes 1577495724967111 The ID of the other Alibaba Cloud account that owns the instance.
crossAccountRoleName String Yes dw-ds2.0-role The name of the RAM role assumed by the other Alibaba Cloud account.
envType String Yes Dev The environment type. Valid values: Dev (development environment), Prod (production environment).

Connection string mode

Use this mode to connect directly using a host address and port, without specifying an instance ID.

Parameter Type Required Example Description
database String Yes database_demo The name of the AnalyticDB for MySQL database.
username String Yes xxxxx The username for accessing the database.
password String Yes xxxxx The password for accessing the database.
address JSON Array Yes [{"host": "127.0.0.1", "port": 3306}] The connection address. Specify a single host and port pair in JSON array format.
properties JSONObject No Advanced parameters for the Java Database Connectivity (JDBC) connection, such as connectTimeout.
envType String Yes Dev The environment type. Valid values: Dev (development environment), Prod (production environment).

Configuration examples

Current-account instance mode

{
    "database": "database",
    "password": "***",
    "instanceId": "am-uf6z88b2xi4niv71p",
    "regionId": "cn-shanghai",
    "envType": "Dev",
    "username": "username"
}

Cross-account instance mode

{
    "database": "database",
    "password": "***",
    "instanceId": "am-uf6z88b2xi4niv71p",
    "regionId": "cn-shanghai",
    "envType": "Dev",
    "username": "username",
    "crossAccountOwnerId": "1853195337009715",
    "crossAccountRoleName": "dw-ds2.0-role"
}

Connection string mode

{
    "address": [
        {
            "host": "127.0.0.1",
            "port": 5432
        }
    ],
    "database": "db",
    "properties": {
        "connectTimeout": "2000"
    },
    "username": "aliyun",
    "password": "xxx",
    "envType": "Dev"
}