Tutorial: Grant permissions to a RAM user and prepare a database account before data development

Updated at:
Copy as MD

When you use a Resource Access Management (RAM) user to log on to the Alibaba Cloud Management Console and access cloud resources, the RAM user is the authenticated entity. You must grant the RAM user the required permissions for the cloud resources. However, AnalyticDB for MySQL databases use database accounts for authentication. Therefore, before you use a RAM user to develop data in AnalyticDB for MySQL, you must grant the RAM user management permissions for the cluster, such as AliyunADBFullAccess, and operation permissions for the database, such as read, write, and alter permissions. This ensures that the RAM user can access the cluster and read and write data.

Step 1: Grant permissions to the RAM user

A RAM user requires different permissions to develop SQL jobs and Spark jobs. The required permissions and authorization methods are as follows:

Develop XIHE SQL jobs as a RAM user

Required permissions

AliyunADBFullAccess: Permissions to manage AnalyticDB for MySQL clusters.

Authorization method

Use an Alibaba Cloud account to grant permissions to a RAM user.

Develop Spark jobs as a RAM user

Required permissions

  • AliyunADBDeveloperAccess: Developer permissions for an AnalyticDB for MySQL cluster.

  • AliyunADBSparkProcessingDataRole: This role is used to authorize AnalyticDB for MySQL Spark to access other cloud resources within the same account, such as OSS directories and Tablestore data.

  • Permissions to access resources of other Alibaba Cloud accounts (Optional): For example, if Alibaba Cloud account A needs to access data in Alibaba Cloud account B, you must create a RAM role for account B and a RAM user for account A. Then, you must grant the RAM user the permission to assume the RAM role of account B to complete data development.

Authorization method

Use an Alibaba Cloud account to grant permissions to the RAM user. For more information, see Manage RAM user permissions and Account authorization.

Step 2: Create a standard database account

  1. Log on to the AnalyticDB for MySQL console.

  2. On the Accounts > Database Accounts page of the cluster, click Create Account.

  3. From the Account Type drop-down list, select Standard Account. Configure parameters such as the account name and password, and then click OK.

For more information, see Create a database account.

Step 3: Grant permissions to the standard database account

By default, a standard database account does not have any permissions for databases or tables. You can use XIHE SQL or log on to the AnalyticDB for MySQL console to manually grant operation permissions for databases and tables to the standard database account.

  1. On the Database Accounts page, find the standard account, click Permissions in the Actions column, and then click Edit Permissions from the drop-down list.

  2. In the Authorization Level drop-down list and the Permission Configuration section, select a permission level and the corresponding permissions, and then click the image button.

  3. Click OK to complete the authorization.

For more information about how to grant permissions using SQL statements and the detailed steps for granting permissions in the console, see GRANT and Grant permissions to a database account.

Step 4: Attach a RAM user to a database account

When you develop data in the AnalyticDB for MySQL console, AnalyticDB for MySQL verifies whether the currently logged-on RAM user has permission to access AnalyticDB for MySQL data. Therefore, you must attach the standard database account to the RAM user to ensure that the RAM user can read and write data in the databases and tables.

  1. On the Database Accounts page, find the destination account and click Manage RAM Association in the Actions column.

  2. In the Manage RAM Association panel, enter the RAM User ID and click OK.

    Note

    After the attachment, AnalyticDB for MySQL checks whether the current RAM user has sufficient permissions based on the attachment relationship before performing any operation. If you want to use another RAM user for data development, see What to do next to modify the attachment relationship.

For more information, see Attach a RAM user to a database account.

What to do next

If you no longer need to use the RAM user for data development, or if you want to modify the attachment relationship between the standard database account and the RAM user, you can modify or detach the attachment, or delete the standard database account.

Modify or detach the RAM user attachment

  1. On the Database Accounts page, find the destination account and click Manage RAM Association in the Actions column.

  2. In the Manage RAM Association panel, click the image button next to RAM User ID.

  3. Enter the RAM User ID of the new RAM user. This step is required only if you want to modify the attachment. You can skip this step if you want to detach the RAM user.

  4. Click OK.

For more information, see Detach or modify the attachment of a RAM user and a database account.

Delete the standard database account

  1. Go to the Accounts > Database Accounts page.

  2. Find the standard account and click Delete in the Actions column.