top of page



{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 [HELP ALTER USER]). 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

SET DEFAULT ROLE requires these privileges:

o Setting the default roles for another user requires the global CREATE
USER privilege, or the UPDATE privilege for the mysql.default_roles
system table.

o Setting the default roles for yourself requires no special
privileges, as long as the roles you want as the default have been
granted to you.

Each role name uses the format described in 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:

o NONE: Set the default to NONE (no roles).

o ALL: Set the default to all roles granted to the account.

o role [, role ] ...: Set the default to the named roles, which must
exist and be granted to the account at the time SET DEFAULT ROLE is


bottom of page