The Alibaba Cloud Command Line Interface (CLI) is a universal command-line tool based on OpenAPI. You can use the CLI to automate the management and maintenance of AnalyticDB for MySQL. This topic describes how to use the CLI to call AnalyticDB for MySQL operations and provides an example.
Prerequisites
If you are not familiar with the Alibaba Cloud CLI, see What is Alibaba Cloud CLI?.
Install the Alibaba Cloud CLI
Before you can use the Alibaba Cloud CLI, you must install it. The Alibaba Cloud CLI can be installed on Windows, Linux, and macOS. Follow the installation instructions for your operating system.
Windows: Install the CLI on Windows.
Linux: Install the CLI on Linux.
macOS: Install the CLI on macOS.
You can also use Cloud Shell to test Alibaba Cloud CLI commands. For more information, see What is Cloud Shell?.
Configure the Alibaba Cloud CLI
Using an Alibaba Cloud account to call APIs poses a high security risk because the account has full access permissions. For improved security, create and use a Resource Access Management (RAM) user for API calls and daily operations and maintenance (O&M).
Before you can use the Alibaba Cloud CLI, you must configure your identity credentials and a region ID. The Alibaba Cloud CLI supports multiple types of identity credentials. For more information, see Credential types. This topic uses AccessKey credentials as an example. The procedure is as follows:
Create a RAM user and grant the required permissions. For more information, see Create a RAM user and Grant permissions to a RAM user.
ImportantThis example requires you to grant the
AliyunADBFullAccessaccess policy to the RAM user. In practice, grant permissions as needed before you make API calls.After you create the RAM user and grant permissions, create an AccessKey pair for the user. Record the
AccessKey IDandAccessKey secretfor later use in configuring credentials. For more information, see Create an AccessKey.Obtain and record the ID of an available region. The Alibaba Cloud CLI sends API requests to the region that you specify. For available regions for Data Lakehouse, Basic, and Enterprise editions, see Endpoints.
NoteYou can use the
--regionoption to specify a region for a single command. This option overrides the region specified in the default credential configuration and environment variables. For more information, see Command-line options.Use the AccessKey pair of the RAM user to configure the AccessKey credentials. Name the configuration profile
AkProfile. For more information, see Configuration examples.
Generate a CLI command example
Go to the Data Lakehouse, Basic, and Enterprise editions API Debugging page.
In the search box on the left, search for the API you want to use. On the Parameters tab, enter the parameters as described in the API documentation. Click the CLI Example tab to the right of the Parameters tab to generate a command example with the parameters that you entered.

Click the
button to open Cloud Shell and quickly test the command.Click the
button to copy the CLI example to the clipboard. You can then paste it into your local shell tool to run the command.When you copy the example to your local shell for testing, note the parameter format. For more information about the parameter formats for the Alibaba Cloud CLI, see Parameter formats.
The OpenAPI Explorer automatically adds the
--regionoption to the generated example. When you run the command locally, the Alibaba Cloud CLI overrides the default region and uses the specified region. You can remove or keep this option as required.
Call an API
Command structure
The general command structure for the Alibaba Cloud CLI is as follows. For more information, see Generate and call a command.
aliyun <command> <subcommand> [options and parameters]Common command options
You can use command options to modify the default behavior of a command or provide additional features. Common options include the following:
--profile <profileName>: Use the--profileoption to specify a configuration profile. ReplaceprofileNamewith a valid profile name. This option overrides the default credential configuration and environment variables.--help: To obtain help information for a command, add the--helpoption at any command level. For more information, see Get help information.
For more information, see Command-line options.
Example
This example shows how to use the Alibaba Cloud CLI to call the DescribeDBClusterAttribute operation in AnalyticDB for MySQL. This operation queries information about a specific Data Lakehouse, Basic, or Enterprise edition cluster. For more information about the DescribeDBClusterAttribute operation, see DescribeDBClusterAttribute.
Run the command.
aliyun adb DescribeDBClusterAttribute --region cn-hangzhou --DBClusterId 'amv-bp15yg4o68****' --version 2021-12-01 --method POST --forceOutput
{ "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****" }