Note
- This view is available starting with V4.3.1 in V4.3.x.
- This view is available starting with V4.2.3 in V4.2.x.
Purpose
The mysql.default_roles view displays information about the roles enabled by default for users.
Columns
| Column | Type | Nullable | Description |
|---|---|---|---|
| HOST | varchar(255) | NO | The Host name of the account. |
| USER | varchar(128) | NO | The account name. |
| DEFAULT_ROLE_HOST | varchar(255) | NO | The Host name of the role enabled by default. |
| DEFAULT_ROLE_USER | varchar(128) | NO | The account name of the role enabled by default. |
Sample query
Query the default roles enabled for the user001 user.
Create a role named
role1.obclient [oceanbase]> CREATE ROLE IF NOT EXISTS role1; Query OK, 0 rows affected, 1 warningGrant the
ALTER SYSTEMprivilege to therole1role.obclient [oceanbase]> GRANT ALTER SYSTEM ON *.* TO role1;Create a user named
user001.obclient [oceanbase]> CREATE USER 'user001'@'%' IDENTIFIED BY '******';Grant the
role1role to the newly createduser001user.obclient [oceanbase]>GRANT role001 TO user001 WITH ADMIN OPTION;;Specify that all roles granted to the
user001user are activated by default upon login.obclient > SET DEFAULT ROLE ALL TO user001;Query the default roles enabled for the
user001user.obclient > SELECT * FROM mysql.default_roles;The query result is as follows:
+------+---------+-------------------+-------------------+ | HOST | USER | DEFAULT_ROLE_HOST | DEFAULT_ROLE_USER | +------+---------+-------------------+-------------------+ | % | user001 | % | role001 | +------+---------+-------------------+-------------------+ 1 row in set (0.001 sec)
References
- View the grant relationships between roles and users: mysql.role_edges
- For more information about user roles, see View roles.