All Products
Search
Document Center

PolarDB:GrantAccountPrivilege

Last Updated:Jun 10, 2026

Memberikan akun standar izin untuk mengakses satu atau beberapa database dalam Kluster PolarDB Basis Data Relasional Cloud-Native tertentu.

Deskripsi operasi

Catatan
  • An account can be authorized to access one or more databases.

  • If the specified account already has the access permissions on the specified databases, the operation returns a successful response.

  • Before you call this operation, make sure that the cluster is in the Running state. Otherwise, the operation fails.

  • This operation is supported only for PolarDB for MySQL clusters.

  • By default, a privileged account for a cluster has all the permissions on the databases in the cluster.

Coba sekarang

Coba API ini di OpenAPI Explorer tanpa perlu penandatanganan manual. Panggilan yang berhasil akan secara otomatis menghasilkan contoh kode SDK sesuai dengan parameter Anda. Unduh kode tersebut dengan kredensial bawaan yang aman untuk penggunaan lokal.

Test

RAM authorization

Tabel berikut menjelaskan otorisasi yang diperlukan untuk memanggil API ini. Anda dapat menentukannya dalam kebijakan Resource Access Management (RAM). Kolom pada tabel dijelaskan sebagai berikut:

  • Action: Aksi yang dapat digunakan dalam elemen Action pada pernyataan kebijakan izin RAM untuk memberikan izin guna melakukan operasi tersebut.

  • API: API yang dapat Anda panggil untuk melakukan aksi tersebut.

  • Access level: Tingkat akses yang telah ditentukan untuk setiap API. Nilai yang valid: create, list, get, update, dan delete.

  • Resource type: Jenis resource yang mendukung otorisasi untuk melakukan aksi tersebut. Ini menunjukkan apakah aksi tersebut mendukung izin tingkat resource. Resource yang ditentukan harus kompatibel dengan aksi tersebut. Jika tidak, kebijakan tersebut tidak akan berlaku.

    • Untuk API dengan izin tingkat resource, jenis resource yang diperlukan ditandai dengan tanda bintang (*). Tentukan Nama Sumber Daya Alibaba Cloud (ARN) yang sesuai dalam elemen Resource pada kebijakan.

    • Untuk API tanpa izin tingkat resource, ditampilkan sebagai All Resources. Gunakan tanda bintang (*) dalam elemen Resource pada kebijakan.

  • Condition key: Kunci kondisi yang didefinisikan oleh layanan. Kunci ini memungkinkan kontrol granular, berlaku baik hanya untuk aksi maupun untuk aksi yang terkait dengan resource tertentu. Selain kunci kondisi spesifik layanan, Alibaba Cloud menyediakan serangkaian common condition keys yang berlaku di semua layanan yang didukung RAM.

  • Dependent action: Aksi dependen yang diperlukan untuk menjalankan aksi tersebut. Untuk menyelesaikan aksi tersebut, pengguna RAM atau role RAM harus memiliki izin untuk melakukan semua aksi dependen.

Action

Access level

Resource type

Condition key

Dependent action

polardb:GrantAccountPrivilege

update

*dbcluster

acs:polardb:{#regionId}:{#accountId}:dbcluster/{#dbclusterId}

None None

Parameter permintaan

Parameter

Type

Required

Description

Example

DBClusterId

string

Yes

ID Kluster.

pc-****************

AccountName

string

Yes

Nama pengguna akun.

testacc

DBName

string

Yes

Nama database yang dapat diakses oleh akun. Anda dapat memberikan izin akses pada satu atau beberapa database kepada akun standar tertentu. Untuk menentukan beberapa nama database, pisahkan nama database dengan koma (,).

testdb_1,testdb_2

AccountPrivilege

string

Yes

Izin yang diberikan kepada akun. Nilai valid:

  • ReadWrite: izin baca dan tulis

  • ReadOnly: izin hanya baca

  • DMLOnly: Akun diberikan izin untuk menjalankan hanya pernyataan DML pada database.

  • DDLOnly: Akun diberikan izin untuk menjalankan hanya pernyataan DDL pada database.

  • ReadIndex: Akun memiliki izin baca dan Indeks pada database.

Catatan

Jumlah nilai AccountPrivilege harus konsisten dengan jumlah nilai DBName. Setiap izin akun harus sesuai dengan nama database secara berurutan. Sebagai contoh, Anda dapat mengatur DBName ke testdb_1,testdb_2 dan mengatur AccountPrivilege ke ReadWrite,ReadOnly. Dalam kasus ini, akun standar tertentu diberikan izin baca dan tulis pada database testdb_1 dan izin baca pada database testdb_2.

ReadWrite,ReadOnly

Elemen respons

Element

Type

Description

Example

object

RequestId

string

The ID of the request.

2FED790E-FB61-4721-8C1C-07C627*****

Contoh

Respons sukses

JSONformat

{
  "RequestId": "2FED790E-FB61-4721-8C1C-07C627*****"
}

Respons error

JSONformat

{
   "RequestId": "2FED790E-FB61-4721-8C1C-07C627FA5A19"
}

Kode kesalahan

HTTP status code

Error code

Error message

Description

400 EngineMigration.ActionDisabled Specified action is disabled while custins is in engine migration. The specified operation is disabled when custins is being migrated across engines.
400 LockTimeout The request processing has failed due to lock timeout. Failed to process the request due to a lock timeout.
400 Account.UpdateError Instance %s update Account %s error Failed to update account %s for cluster %s.
400 InvalidDBName.Malformed The specified parameter DBName is not valid. The format of the specified database name is invalid.
400 InvalidAccountName.Malformed The specified parameter AccountName is not valid. The specified AccountName parameter is invalid.
400 InvalidAccountPrivilege.Malformed The specified parameter AccountPrivilege is not valid. The specified AccountPrivilege parameter is invalid.
403 IncorrectAccountPrivilegeType Current account privilege type does not support this operation. The permission type of the current account does not support this operation.
404 InvalidDBCluster.NotFound The DBClusterId provided does not exist in our records. The specified DBClusterId parameter does not exist in the current record.
404 InvalidDBClusterId.Malformed The specified parameter DBClusterId is not valid. The specified DBClusterId parameter is invalid.
404 InvalidDBClusterId.NotFound The DBInstanceId provided does not exist in our records. The specified DBClusterId parameter does not exist in the current record.

Lihat Error Codes untuk daftar lengkap.

Catatan rilis

Lihat Release Notes untuk daftar lengkap.