Documentation Home
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 32.3Mb
PDF (A4) - 32.3Mb
PDF (RPM) - 30.4Mb
HTML Download (TGZ) - 7.8Mb
HTML Download (Zip) - 7.8Mb
HTML Download (RPM) - 6.7Mb
Man Pages (TGZ) - 142.5Kb
Man Pages (Zip) - 201.7Kb
Info (Gzip) - 3.0Mb
Info (Zip) - 3.0Mb


Pre-General Availability Draft: 2017-05-25

14.7.1.9 SET DEFAULT ROLE Syntax

SET DEFAULT ROLE
    {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 14.7.1.1, “ALTER USER Syntax”). However, ALTER USER can set the default for only a single user, whereas SET DEFAULT ROLE can set the default for multiple users.

SET DEFAULT ROLE requires these privileges:

  • To set the default roles for another user: The global CREATE USER privilege, or the UPDATE privilege for the mysql.default_roles system table.

  • To set the default roles for yourself: 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 Section 7.2.5, “Specifying Role Names”. For example:

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

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

The clause following the DEFAULT ROLE keywords permits these values:

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

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

  • role [, role ] ...: Set the default to the named roles, which need not exist or be granted to the account at the time SET DEFAULT ROLE is executed.

Note

SET DEFAULT ROLE and SET ROLE DEFAULT are different statements. The first defines which roles to activate by default within sessions for an account. The second sets the active roles within the current session to the current account default roles.


User Comments
Sign Up Login You must be logged in to post a comment.