13.7.7.12 SHOW CREATE USER Statement语句

SHOW CREATE USER user

This statement shows the CREATE USER statement that creates the named user. 此语句显示创建命名用户的CREATE USER语句。An error occurs if the user does not exist. 如果用户不存在,则会发生错误。The statement requires the SELECT privilege for the mysql system schema, except to see information for the current user. 该语句要求mysql系统模式具有SELECT权限,但查看当前用户的信息除外。For the current user, the SELECT privilege for the mysql.user system table is required for display of the password hash in the IDENTIFIED AS clause; otherwise, the hash displays as <secret>.对于当前用户,在IDENTIFIED AS子句中显示密码哈希需要mysql.user系统表的SELECT权限;否则,散列显示为<secret>

To name the account, use the format described in Section 6.2.4, “Specifying Account Names”. 要命名帐户,请使用第6.2.4节,“指定帐户名称”中描述的格式。The host name part of the account name, if omitted, defaults to '%'. It is also possible to specify CURRENT_USER or CURRENT_USER() to refer to the account associated with the current session.帐户名的主机名部分(如果省略)默认为'%'。也可以指定CURRENT_USERCURRENT_SER()来引用与当前会话关联的帐户。

Password hash values displayed in the IDENTIFIED WITH clause of output from SHOW CREATE USER may contain unprintable characters that have adverse effects on terminal displays and in other environments. SHOW CREATE USER输出的IDENTIFIED WITH子句中显示的密码哈希值可能包含不可打印的字符,这些字符会对终端显示和其他环境产生不利影响。Enabling the print_identified_with_as_hex system variable (available as of MySQL 8.0.17) causes SHOW CREATE USER to display such hash values as hexadecimal strings rather than as regular string literals. 启用print_identified_with_as_hex系统变量(从MySQL 8.0.17起可用)会导致SHOW CREATE USER将此类哈希值显示为十六进制字符串,而不是常规字符串文字。Hash values that do not contain unprintable characters still display as regular string literals, even with this variable enabled.即使启用了此变量,不包含不可打印字符的哈希值仍显示为常规字符串文字。

mysql> CREATE USER 'u1'@'localhost' IDENTIFIED BY 'secret';
mysql> SET print_identified_with_as_hex = ON;
mysql> SHOW CREATE USER 'u1'@'localhost'\G
*************************** 1. row ***************************
CREATE USER for u1@localhost: CREATE USER 'u1'@'localhost'
IDENTIFIED WITH 'caching_sha2_password'
AS 0x244124303035240C7745603626313D613C4C10633E0A104B1E14135A544A7871567245614F4872344643546336546F624F6C7861326932752F45622F4F473273597557627139
REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK
PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT
PASSWORD REQUIRE CURRENT DEFAULT

To display the privileges granted to an account, use the SHOW GRANTS statement. See Section 13.7.7.21, “SHOW GRANTS Statement”.要显示授予帐户的权限,请使用SHOW GRANTS语句。参见第13.7.7.21节,“SHOW GRANTS语句”