You can execute the GRANT statement to grant permissions to an account.

GRANT
    priv_type [(column_list)]
      [, priv_type [(column_list)]] ...
    ON priv_level
    TO user [auth_option]
    [WITH {GRANT OPTION}]     

Parameters

  • priv_type: the type of the permission to grant. For more information, see Permission model.
  • column_list: optional. If the priv_type parameter is set to SELECT, you can enter the names of columns to grant the SELECT permission on these columns.
  • priv_level: the level of the permission to grant.
    • *.*: the cluster level.
    • db_name.*: the database level.
    • db_name.table_name or table_name: the table level.

Precautions

To grant permissions to the other accounts by executing the GRANT statement, you must have the GRANT OPTION permission.

Example

  • Grant the cluster-level all permission to account2.
    GRANT all ON *.* TO 'account2';                
  • Grant the database-level all permission to account3.
    GRANT all ON adb_demo.* TO 'account3';                 
  • Execute the GRANT statement to create an account and grant permissions to it.

    For example, create an account with the cluster-level data manipulation permissions.

    GRANT insert,select,update,delete on *.* to 'test'@'%' identified by 'Testpassword1';                 

    Create an account with the database-level data manipulation permissions.

    GRANT insert,select,update,delete on adb_demo.* to 'test123' identified by 'Testpassword123';                 
  • Create an account that has the SELECT permission on the specified columns.
    GRANT select (customer_id, sex) ON customer TO 'test321' identified by 'Testpassword321';