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 thepriv_typeparameter is set toSELECT, you can enter the names of columns to grant theSELECTpermission on these columns.priv_level: the level of the permission to grant.*.*: the cluster level.db_name.*: the database level.db_name.table_nameortable_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
allpermission to account2.GRANT all ON *.* TO 'account2'; - Grant the database-level
allpermission to account3.GRANT all ON adb_demo.* TO 'account3'; - Execute the
GRANTstatement 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
SELECTpermission on the specified columns.GRANT select (customer_id, sex) ON customer TO 'test321' identified by 'Testpassword321';