You can create a role, grant privileges to the role, and manage privileges by role.
Create a role by using an SQL statement
You can use the CREATE ROLE statement to create a role. To create a role, you must have the CREATE ROLE privilege. For more information, see View user privileges. If you do not have the CREATE ROLE privilege, contact an administrator. For more information, see Modify user privileges.
SQL syntax:
CREATE ROLE role_name
[ NOT IDENTIFIED
| IDENTIFIED BY password
] ;
Notes:
NOT IDENTIFIED: If you specify this clause, a new role is not verified when it is enabled.IDENTIFIED BY password: This clause specifies the password to enable a role. If you specify this clause and assign the role to a user, the user must specify the password in theSET ROLEstatement to enable the role.If you do not specify the
NOT IDENTIFIEDorIDENTIFIED BY passwordclause, theNOT IDENTIFIEDclause is used for a new role by default.
Examples:
Create the
role1role:obclient> CREATE ROLE role1; Query OK, 0 rows affectedCreate a role named
role2and set its password to******.obclient> CREATE ROLE role2 IDENTIFIED BY ******; Query OK, 0 rows affectedFor more information about the
CREATE ROLEstatement, see CREATE ROLE.