All Products
Search
Document Center

AnalyticDB:CLI integration example

Last Updated:Mar 28, 2026

Use the Alibaba Cloud Command Line Interface (CLI) to automate the management and maintenance of AnalyticDB for MySQL clusters. This document walks you through installing and configuring the CLI, generating a command example from API Debugging, and calling your first API operation.

Prerequisites

Before you begin, ensure that you have:

  • An Alibaba Cloud account with AnalyticDB for MySQL clusters to manage

  • (Optional) Familiarity with the CLI — see What is Alibaba Cloud CLI? for an overview

Install the CLI

The Alibaba Cloud CLI runs on Windows, Linux, and macOS. Follow the installation guide for your operating system:

After installation, confirm the CLI is working:

aliyun --version

To test CLI commands without a local installation, use Cloud Shell. For details, see What is Cloud Shell?.

Configure the CLI

Important

Using an Alibaba Cloud account to call APIs poses a high security risk because the account has full access permissions. Create and use a Resource Access Management (RAM) user for API calls and daily operations and maintenance (O&M).

Before running CLI commands, gather the following information:

InformationWhere to get it
AccessKey IDCreate an AccessKey for a RAM user
AccessKey secretSame as above — record it immediately, as it is only shown once
Region IDEndpoints page for available regions across Data Lakehouse, Basic, and Enterprise editions

Then follow these steps:

  1. Create a RAM user and grant it the required permissions. See Create a RAM user and Grant permissions to a RAM user.

    Important

    This example requires the AliyunADBFullAccess access policy. In practice, grant only the permissions needed for each specific API call.

  2. Create an AccessKey pair for the RAM user. Record the AccessKey ID and AccessKey secret for use in the next step. See Create an AccessKey.

  3. Note the region ID for the region where your clusters reside. See Endpoints for available regions.

    Note

    Use the --region option to override the default region for a single command. This takes precedence over the region set in the credential configuration and environment variables. See Command-line options.

  4. Configure an AccessKey credential profile named AkProfile using the AccessKey pair. See Configuration examples for the full procedure.

The CLI supports multiple credential types. For a complete list, see Credential types.

Generate a CLI command example

Use the API Debugging page to generate a ready-to-run CLI command for any AnalyticDB for MySQL operation:

  1. Go to the Data Lakehouse, Basic, and Enterprise editions API Debugging page.API Debugging

  2. Search for the API operation in the left panel. On the Parameters tab, fill in the parameters. Then click CLI Example to see the generated command. When running the command locally, note that:

    • The generated command includes --region by default. Remove or keep this option as needed.

    • Parameter formats for the CLI may differ from the API documentation. See Parameter formats.

    image

Call an API

Command structure

All Alibaba Cloud CLI commands follow this structure. See Generate and call a command for details.

aliyun <command> <subcommand> [options and parameters]

Common options

OptionDescription
--profile <profileName>Specify a credential profile by name. Overrides the default credential configuration and environment variables.
--region <regionId>Override the default region for a single command.
--helpShow help information at any command level. See Get help information.

For the full list, see Command-line options.

Example: query cluster details

The following example calls DescribeDBClusterAttribute to retrieve details for a specific Data Lakehouse, Basic, or Enterprise edition cluster. See DescribeDBClusterAttribute for the full API reference.

  1. Run the command. Replace amv-bp15yg4o68**** with your cluster ID and cn-hangzhou with your region ID.

    aliyun adb DescribeDBClusterAttribute --region cn-hangzhou --DBClusterId 'amv-bp15yg4o68****' --version 2021-12-01 --method POST --force
  2. A successful response returns a JSON object with cluster details:

    {
        "Items": {
            "DBCluster": [
                {
                    "ClickhouseEngineCacheSize": -1,
                    "ClickhouseEngineEnabled": false,
                    "CommodityCode": "ads",
                    "ComputeResource": "0ACU",
                    "ComputeResourceTotal": "0ACU",
                    "ConnectionString": "amv-bp15yg4o68****.ads.aliyuncs.com",
                    "CreationTime": "2024-09-26T05:25:46Z",
                    "DBClusterDescription": "amv-bp15yg4o68****",
                    "DBClusterId": "amv-bp15yg4o68****",
                    "DBClusterNetworkType": "VPC",
                    "DBClusterStatus": "Running",
                    "DBClusterType": "Common",
                    "DBVersion": "5.0",
                    "Engine": "3.2.X.X",
                    "EngineVersion": "3.2.2.2",
                    "ExpireTime": "",
                    "KmsId": "",
                    "LockMode": "Unlock",
                    "LockReason": "",
                    "MaintainTime": "15:00Z-16:00Z",
                    "Mode": "flexible",
                    "PayType": "Postpaid",
                    "Port": "3306",
                    "ProductForm": "IntegrationForm",
                    "ProductVersion": "EnterpriseVersion",
                    "RegionId": "cn-hangzhou",
                    "ReservedACU": "0ACU",
                    "ReservedNodeCount": 3,
                    "ReservedNodeSize": "8ACU",
                    "ResourceGroupId": "rg-acfmz7u4zzrngoa",
                    "StorageResource": "24ACU",
                    "StorageResourceTotal": "24ACU",
                    "SupportedFeatures": {
                        "AutoMC": true,
                        "ClickhouseEngine": true
                    },
                    "UserENIStatus": false,
                    "VPCId": "vpc-bp15lqdl91m0fdc****",
                    "VSwitchId": "vsw-bp1k9jdi0yznq****",
                    "ZoneId": "cn-hangzhou-k"
                }
            ]
        },
        "RequestId": "C42A167C-620C-5CF4-B016-663E3****"
    }

What's next