DROP ROLE [IF EXISTS]role
[,role
] ...
DROP ROLE
removes one or more roles (named collections of privileges). DROP ROLE
删除一个或多个角色(命名的权限集合)。To use this statement, you must have the global 要使用此语句,您必须具有全局DROP ROLE
or CREATE USER
privilege. DROP ROLE
或CREATE USER
权限。When the 启用read_only
system variable is enabled, DROP ROLE
additionally requires the CONNECTION_ADMIN
privilege (or the deprecated SUPER
privilege).read_only
系统变量时,DROP ROLE
还需要CONNECTION_ADMIN
权限(或不推荐使用的SUPER
权限)。
As of MySQL 8.0.16, users who have the 从MySQL 8.0.16开始,拥有CREATE USER
privilege can use this statement to drop accounts that are locked or unlocked. CREATE USER
权限的用户可以使用此语句删除已锁定或解锁的帐户。Users who have the 具有DROP ROLE
privilege can use this statement only to drop accounts that are locked (unlocked accounts are presumably user accounts used to log in to the server and not just as roles).DROP ROLE
权限的用户只能使用此语句删除已锁定的帐户(未锁定的帐户可能是用于登录服务器的用户帐户,而不仅仅是角色)。
Roles named in the 无法删除在mandatory_roles
system variable value cannot be dropped.mandatory_roles
系统变量值中命名的角色。
DROP ROLE
either succeeds for all named roles or rolls back and has no effect if any error occurs. DROP ROLE
要么对所有命名角色成功,要么回滚,如果发生任何错误,则不起作用。By default, an error occurs if you try to drop a role that does not exist. 默认情况下,如果试图删除不存在的角色,则会发生错误。If the 如果给出IF EXISTS
clause is given, the statement produces a warning for each named role that does not exist, rather than an error.IF EXISTS
子句,则该语句会为每个不存在的命名角色生成警告,而不是错误。
The statement is written to the binary log if it succeeds, but not if it fails; in that case, rollback occurs and no changes are made. 如果语句成功,则将其写入二进制日志,但如果失败,则不会写入;在这种情况下,会发生回滚,并且不会进行任何更改。A statement written to the binary log includes all named roles. 写入二进制日志的语句包含所有命名角色。If the 如果给出了IF EXISTS
clause is given, this includes even roles that do not exist and were not dropped.IF EXISTS
子句,则甚至包括不存在且未删除的角色。
Each role name uses the format described in Section 6.2.5, “Specifying Role Names”. For example:每个角色名称使用第6.2.5节,“指定角色名称”中描述的格式。例如:
DROP ROLE 'admin', 'developer'; DROP ROLE 'webapp'@'localhost';
The host name part of the role name, if omitted, defaults to 角色名的主机名部分(如果省略)默认为'%'
.'%'
。
A dropped role is automatically revoked from any user account (or role) to which the role was granted. 删除的角色将自动从授予该角色的任何用户帐户(或角色)中撤销。Within any current session for such an account, its adjusted privileges apply beginning with the next statement executed.在此类帐户的任何当前会话中,其调整后的权限将从执行下一条语句开始应用。
For role usage examples, see Section 6.2.10, “Using Roles”.有关角色使用示例,请参阅第6.2.10节,“使用角色”。