MySQL 8.0 Reference Manual Including MySQL NDB Cluster 8.0 SET DEFAULT ROLE Statement

    {NONE | ALL | role [, role ] ...}
    TO user [, user ] ...

For each user named immediately after the TO keyword, this statement defines which roles become active when the user connects to the server and authenticates, or when the user executes the SET ROLE DEFAULT statement during a session.

SET DEFAULT ROLE is alternative syntax for ALTER USER ... DEFAULT ROLE (see Section, “ALTER USER Statement”). However, ALTER USER can set the default for only a single user, whereas SET DEFAULT ROLE can set the default for multiple users. On the other hand, you can specify CURRENT_USER as the user name for the ALTER USER statement, whereas you cannot for SET DEFAULT ROLE.

SET DEFAULT ROLE requires these privileges:

Each role name uses the format described in Section 6.2.5, “Specifying Role Names”. For example:

SET DEFAULT ROLE administrator, developer TO 'joe'@'';

The host name part of the role name, if omitted, defaults to '%'.

The clause following the DEFAULT ROLE keywords permits these values:


SET DEFAULT ROLE and SET ROLE DEFAULT are different statements:

  • SET DEFAULT ROLE defines which account roles to activate by default within account sessions.

  • SET ROLE DEFAULT sets the active roles within the current session to the current account default roles.

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