# create mysql instance - CreateUDBMySQLInstance

## Overview

Create UDB instances (including creating MySQL NVMe, shared, and O2 instances as well as restoring instances from backups)

 > 💡 Before creation, it is recommended to call `DescribeUDBType` to retrieve `DBTypeId`, `ListUDBMachineType` to retrieve `MachineType`/`StorageClass`/`SpecificationClass`, and `DescribeUDBParamGroup` to retrieve `ParamGroupId` (`RegionFlag=true` is required for cross-availability zone (HA) queries). After successfully returning `DBId`, use `DescribeUDBInstance` or `DescribeUDBInstanceState` to poll to Running. For pricing inquiries, first call `DescribeUDBInstancePrice`.  Notes on creating cross-availability zone high availability:  1. Required parameter: BackupZone: value is the ZoneId for high availability and disaster recovery;  2. Parameter: ParamGroupId: value is the configuration file for the cross-availability zone, which can be obtained through `DescribeUDBParamGroup`.




## Definition

### Public Parameters

| Parameter Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Action**     | string  | Corresponding API command name, the current API is `CreateUDBMySQLInstance`.                      | **Yes** |
| **PublicKey**  | string  | The user's public key can be obtained from [Console](https://console.sigcalcloud.com/uaccount/api_manage)                                             | **Yes** |
| **Signature**  | string  | User signature generated based on public key and API command, see [Signature Algorithm](/docs/api/summary/signature.md)  | **Yes** |

### Request Parameters

| Parameter Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Region** | string | Region. See [List of Regions and Availability Zones](/docs/api/summary/regionlist) |**Yes**|
| **Zone** | string | Availability Zone. See [Availability Zone List](/docs/api/summary/regionlist) |**Yes**|
| **ProjectId** | string | Project ID. If not filled in, the default project is used, sub-accounts must be filled in. Please refer to the [GetProjectList interface](/docs/api/summary/get_project_list). |No|
| **Name** | string | Instance name, at least 6 characters |**Yes**|
| **AdminPassword** | string | Administrator password. 8-36 characters, accepting uppercase and lowercase letters, numbers, and characters such as @#$%^*-+=_,?!&()\~.\|. Must contain two or more of these character classes. |**Yes**|
| **DBTypeId** | string | DB types are further subdivided by MySQL version: mysql-8.4, mysql-8.0, mysql-5.7, percona-5.7, mysql-5.6, percona-5.6, and mysql-5.5. You can query this using `DescribeUDBType`. |**Yes**|
| **Port** | int | Port number, mysql default 3306 |**Yes**|
| **DiskSpace** | int | Disk space (GB), supporting approximately 20G–32T, with a typical step size of 10; |**Yes**|
| **ParamGroupId** | int | The configuration parameter group ID used by the DB instance can be found in the `GroupId` returned by DescribeUDBParamGroup, and it must match `DBTypeId`. |**Yes**|
| **MachineType** | string | Specification type ID. This field is valid only when SpecificationType = 1. Please retrieve the value through the ListUDBMachineType API. |**Yes**|
| **StorageClass** | string | Storage type: CLOUD_RSSD: RSSD cloud disk, CLOUD_SSD_ESSENTIAL: SSD Essential cloud disk. This field is used in conjunction with SpecificationClass. CLOUD_RSSD corresponds to type O, and CLOUD_SSD_ESSENTIAL corresponds to type OM (supported in Beijing 2 and Ulanqab). Note: São Paulo, Denver, and Kazakhstan regions only support the O2 model, where CLOUD_RSSD corresponds to type O2. This can be read from the same specification field in ListUDBMachineType. |**Yes**|
| **SpecificationClass** | string | Specification Type O: NVME, OM: Shared Type, N: General Type |**Yes**|
| **ChargeType** | string | Yearly, Monthly, Dynamic, Trial, Default: Monthly |No|
| **Quantity** | int | Purchase duration, default value 1 |No|
| **BackupCount** | int | Backup strategy, number of backups per week, default is 7 times |No|
| **BackupTime** | int | Backup strategy, backup start time, calculated in units of hours, default is 1 o'clock |No|
| **BackupDuration** | int | Backup strategy, backup time interval, calculated in hours, default is 24 hours. |No|
| **BackupId** | int | Backup ID, if specified, it means to restore the instance from the backup. |No|
| **InstanceMode** | string | UDB instance mode type, optional values are as follows: "Normal": Standard version UDB instance "HA": High availability version UDB instance The default is "Normal". |No|
| **BackupZone** | string | The availability zone where the cross-availability zone high-availability backup library is located, see [Availability Zone List](/docs/api/summary/regionlist) |No|
| **SubnetId** | string | Subnet ID. Must belong to the same VPC as `VPCId`. |No|
| **VPCId** | string | VPC ID. Used in pairs with `SubnetId`; see the relevant UVPC interfaces for values. |No|
| **DisableSemisync** | boolean | Whether to enable asynchronous high availability, not filled by default, can be set to true |No|
| **Tag** | string | The name of the business group where the instance is located |No|
| **DBSubVersion** | string | MySQL minor version. Specifying a minor version during instance creation is supported. Please use the DescribeUDBType API to obtain the available versions. |No|
| **CaseSensitivityParam** | int | MySQL case sensitivity parameter, 0 for case sensitive, 1 for case insensitive, currently only effective for MySQL 8.0 |No|
| **AlarmTemplateId** | string | ID of the alarm template |No|
| **BackupURL** | string | Internal network address for downloading backup files from US3 |No|
| **SemisyncFlag** | int | Semi-synchronous toggle switch: 1 indicates enabling semi-synchronous, 2 indicates disabling semi-synchronous, 0 indicates the default value, which is also enabling semi-synchronous by default. |No|
| **Labels.N.Key** | string | Keys of User Resource Label |No|
| **Labels.N.Value** | string | Values of User Resource Label |No|
| **CouponId** | string | ID of the voucher used |No|

### Response Field

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **RetCode** | int | Return status code. If it is 0, it means successful return. If it is not 0, it means failure. |**Yes**|
| **Action** | string | Operation command name. |**Yes**|
| **Message** | string | Returns an error message, providing detailed description when `RetCode` is non-zero. |No|
| **DBId** | string | BD Instance ID |No|




## Example

### Request Example
    
```
https://api.sigcalcloud.com/?Action=CreateUDBMySQLInstance
&Region=DHSQjnMH
&Zone=VPbfMFgr
&ProjectId=QqMPIElo
&Name=VJRdgjLz
&AdminPassword=qpuNzHWu
&DBTypeId=mysql-5.7
&Port=1
&DiskSpace=2
&ParamGroupId=1
&SpecificationType=BSzvvsmr
&MachineType=vVzRuiXW
&StorageClass=iFbCPKNS
&SpecificationClass=VyvAhzBv
&ChargeType=fBuCAPrS
&Quantity=7
&AdminUser=BrxrNMhG
&BackupCount=8
&BackupTime=6
&BackupDuration=5
&BackupId=8
&InstanceMode=Normal
&BackupZone=rFyctFJb
&SubnetId=daZLUdLl
&VPCId=hHzobfnk
&DisableSemisync=true
&Tag=fEWwwrJs
&DBSubVersion=8.0.16
&CaseSensitivityParam=6
&AlarmTemplateId=msYGzxTY
&BackupURL=jbeGhHuy
&SemisyncFlag=3
&Labels.N.Key=ZSDypLJv
&Labels.N.Value=VZexUEuN
&CouponId=XasoJFsT
```

### Response Example
    
```json
{
  "Action": "CreateUDBMySQLInstanceResponse",
  "DBId": "JhdlRKKq",
  "RetCode": 0
}
```





