Manage MySQL database account permissions

更新时间:
复制 MD 格式

Data Management Service (DMS) lets you manage fine-grained permissions for MySQL database accounts at the database, table, column, and view levels. This topic describes how to manage MySQL database account permissions in DMS.

Prerequisites

Function introduction

You can manage common permission sets, such as read-only, read/write, DML only, and DDL only, in the consoles for RDS for MySQL and PolarDB for MySQL. For more complex scenarios, such as creating custom permission sets or granting table-level permissions, you can use the database account permission management feature in DMS. For example:

  • Grant Account A the global SELECT and UPDATE permissions.

    Note

    Global permissions apply to the entire database instance. For more information, see MySQL global permissions.

  • Grant Account B the SELECT permission on a single table or the UPDATE permission on a specific column.

    Note

    Object permissions can apply to all database objects or to one or more specific database objects. For more information, see MySQL object permissions.

Create an account

  1. Log in to DMS 5.0.

  2. Log on to the destination database. For more information, see Log on to a database.

  3. On the home page, click the database instance in the navigation pane on the left. In the instance list, right-click the destination instance name and click Database Account Management.

  4. On the Database Account Management page, click Create Database Account in the upper-left corner.

  5. In the dialog box that appears, configure the following parameters.

    1. Click the Basic settings tab and configure the parameters.

      image

      Configuration item

      Description

      Database Account

      The account used to log on to the database.

      Host

      The IP address from which the account is allowed to access the database.

      Note

      If you leave this blank, the account can access the database from any IP address. The default value is %.

      Password

      Enter the logon password.

      Confirm Password

      Enter the logon password again.

      Note

      The SQL statement for the preceding configuration is CREATE USER 'username'@'host' IDENTIFIED BY 'password';.

      To configure Advanced Options, click the Advanced Options button and configure the parameters.

      For example, the SQL statement for the configuration in the following figure is:

      GRANT USAGE ON *.* TO 'username'@'host' WITH MAX_QUERIES_PER_HOUR 100 MAX_UPDATES_PER_HOUR 200 MAX_CONNECTIONS_PER_HOUR 300 MAX_USER_CONNECTIONS 400;

      高级选项界面

    2. Click the Global permissions tab and select the required permissions.

      全局对象界面

      Note

      If you use a standard account and cannot find the required permission, it may be because the permission is not supported by the instance type or your account does not have the required permissions. If your account permissions are insufficient, you can retry the operation using a privileged account.

    3. Click the Object permissions tab and configure the parameters.

      For example, the SQL statement for the configuration in the following figure is:

      GRANT SELECT,INSERT ON `rds_db`.* TO 'username'@'host'; 
       GRANT DELETE ON `rds_db`.`rds_table` TO 'username'@'host';

      对象权限界面

  6. Click Confirm.

  7. In the Preview SQL Statement window, click Confirm.

    Note

    Database instances in Security Collaboration mode are subject to security rules. If the execution fails, follow the on-screen instructions or contact a DBA or an administrator for confirmation. For more information about how to adjust the rules, see the FAQ section.

Edit or delete an account

You can edit an account to modify its username, password, and MySQL global and object permissions.

  1. Log in to DMS 5.0.

  2. On the home page, click the database instance in the navigation pane on the left. In the instance list, right-click the destination instance name and click Database Account Management.

  3. Find the target account and click Edit or Delete.

MySQL global permissions

Permission

Authorized object

Permissions

CREATE

Databases, tables, or indexes

Grants permission to create databases, tables, or indexes.

DROP

Databases, tables, or views

Revoke permissions on a database, table, or view.

GRANT OPTION

Databases, tables, or stored programs

Permission options.

REFERENCES

Databases, tables, or columns

Grants permission to create foreign keys.

LOCK TABLES

Databases

Grants permission to lock tables.

EVENT

Databases

Grants permission to query, create, modify, and delete MySQL events.

ALTER

Tables, views

Grants permission to alter tables or views. For example, add fields, add indexes, or modify fields.

DELETE

Tables

You can delete a database permission.

INDEX

Tables

Index permissions

INSERT

Tables, columns

Grants permission to insert data.

SELECT

Tables, columns

Grants permission to query data.

UPDATE

Tables, columns

Grants permission to update data.

CREATE VIEW

Views

Grants permission to create views.

SHOW VIEW

Views

Grants permission to view views.

TRIGGER

Triggers

Grants permission to create, drop, execute, and show triggers.

ALTER ROUTINE

Stored procedures

Grants permission to alter stored procedures.

CREATE ROUTINE

Stored procedures

Grants permission to create stored procedures.

EXECUTE

Stored procedures

Grants permission to execute stored procedures.

FILE

File access on the server host

File access permissions.

CREATE TEMPORARY TABLES

Server management

Grants permission to create temporary tables.

CREATE USER

Server management

Grants permission to create accounts.

PROCESS

Server management

You can view process permissions.

RELOAD

Server management

Grants permission to execute commands such as FLUSH-HOSTS, FLUSH-LOGS, FLUSH-PRIVILEGES, FLUSH-STATUS, FLUSH-TABLES, FLUSH-THREADS, REFRESH, and RELOAD.

REPLICATION CLIENT

Server management

Grants replication permission.

REPLICATION SLAVE

Server management

Grants replication permission.

SHOW DATABASES

Server management

You can view database permissions.

SHUTDOWN

Server management

Disable the server permission.

SUPER

Server management

Grants permission to kill threads.

Note

RDS for MySQL and RDS for MariaDB do not support the SUPER permission.

MySQL object permissions

Permission

Target Object

Permissions

CREATE

Databases, tables, or indexes

Grants permission to create databases, tables, or indexes.

DROP

Databases, tables, or views

You can revoke permissions on databases, tables, or views.

GRANT OPTION

Databases, tables, or stored programs

Permission granting options

REFERENCES

Databases, tables, or columns

Grants permission to create foreign keys.

LOCK TABLES

Databases

Grants permission to lock tables.

EVENT

Databases

Grants permission to query, create, modify, and delete MySQL events.

ALTER

Tables, views

Grants permission to alter tables or views. For example, add fields, add indexes, or modify fields.

DELETE

Tables

You can delete the database permission.

INDEX

Tables

Index permissions

INSERT

Tables, columns

Grants permission to insert data.

SELECT

Tables, columns

View permissions.

UPDATE

Tables, columns

Grants permission to update data.

CREATE VIEW

Views

Grants permission to create views.

SHOW VIEW

Views

View permissions.

TRIGGER

Triggers

Grants permission to create, drop, execute, and show triggers.

FAQ

Q: When I create a user, an error message indicates that the CREATE_USER command is blocked by security rules. How can I resolve this?error框

A: Follow the steps in the error message dialog box:

  1. Find the name of the security rule set that is attached to the instance.

    On the home page, find the target instance in the instance list on the left. Then, right-click the instance and click View Details.

  2. Adjust the security rule.

    1. Log on to DMS.

    2. In the top menu bar, choose security and disaster recovery (DBS) > security rules.

    3. On the security rules tab, find the target rule set and click Edit in the Actions column.

    4. In the left-side navigation pane, click SQL Correct.

    5. In the Checkpoint field, select SQL Execution Rule.

    6. Select the Allow all DCL statements to be directly executed in the SQL console security rule, and click Edit in the Actions column.

    7. In the Rule DSL section of the Edit Rule dialog box, add the CREATE_USER SQL type.DCL SQL

  3. Click Submit.