SET DEFAULT ROLE {NONE | ALL |role
[,role
] ...} TOuser
[,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.TO
关键字之后命名的每个user
,该语句定义了当用户连接到服务器并进行身份验证时,或者当用户在会话期间执行SET ROLE DEFAULT
语句时,哪些角色变为活动角色。
SET DEFAULT ROLE
is alternative syntax for ALTER USER ... DEFAULT ROLE
(see Section 13.7.1.1, “ALTER USER Statement”). SET DEFAULT ROLE
是ALTER USER ... DEFAULT ROLE
的替代语法(见第13.7.1.1节,“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. ALTER USER
只能为单个用户设置默认值,而SET DEFAULT ROLE
可以为多个用户设置默认值。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
.ALTER USER
语句指定CURRENT_USER
作为用户名,而不能为SET DEFAULT ROLE
指定用户名。
SET DEFAULT ROLE
requires these privileges:需要以下权限:
Setting the default roles for another user requires the global 为其他用户设置默认角色需要全局CREATE USER
privilege, or the UPDATE
privilege for the mysql.default_roles
system table.CREATE USER
权限,或mysql.default_roles
系统表的UPDATE
权限。
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 Section 6.2.5, “Specifying Role Names”. For example:每个角色名称使用第6.2.5节,“指定角色名称”中描述的格式。例如:
SET DEFAULT ROLE 'admin', '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:DEFAULT ROLE
关键字后面的子句允许以下值:
NONE
: Set the default to :将默认设置为NONE
(no roles).NONE
(无角色)。
ALL
: Set the default to all roles granted to the account.:将默认设置为授予帐户的所有角色。
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 executed.SET DEFAULT ROLE
时授予该帐户。
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”.有关角色使用示例,请参阅第6.2.10节,“使用角色”。