MySQL :: MySQL 8.4 Reference Manual :: 15.7.1.11 SET ROLE Statement (original) (raw)

15.7.1.11 SET ROLE Statement

SET ROLE {
    DEFAULT
  | NONE
  | ALL
  | ALL EXCEPT role [, role ] ...
  | role [, role ] ...
}

SET ROLE modifies the current user's effective privileges within the current session by specifying which of its granted roles are active. Granted roles include those granted explicitly to the user and those named in the mandatory_roles system variable value.

Examples:

SET ROLE DEFAULT;
SET ROLE 'role1', 'role2';
SET ROLE ALL;
SET ROLE ALL EXCEPT 'role1', 'role2';

Each role name uses the format described inSection 8.2.5, “Specifying Role Names”. The host name part of the role name, if omitted, defaults to '%'.

Privileges that the user has been granted directly (rather than through roles) remain unaffected by changes to the active roles.

The statement permits these role specifiers:

For role usage examples, see Section 8.2.10, “Using Roles”.