USER_ATTRIBUTES 表提供关于用户评论和用户属性的信息。它的值取自 mysql.user 系统表。The USER_ATTRIBUTES table provides
information about user comments and user attributes. It takes its
values from the mysql.user system table.
USER_ATTRIBUTES 表具有以下列:The USER_ATTRIBUTES table has these
columns:
USERUSER应用于
ATTRIBUTE列值的账户的用户名部分。The user name portion of the account to which theATTRIBUTEcolumn value applies.HOSTHOST应用于
ATTRIBUTE列值的账户的主机名部分。The host name portion of the account to which theATTRIBUTEcolumn value applies.ATTRIBUTE属于由
USER和HOST列指定的帐户的用户评论、用户属性或两者。该值采用 JSON 对象表示法。属性显示如下所设置:使用CREATE USER和ALTER USER语句中的ATTRIBUTE或COMMENT选项。评论以键值对形式显示,键为comment。有关更多信息和示例,请参见 CREATE USER 评论和属性选项。The user comment, user attribute, or both belonging to the account specified by theUSERandHOSTcolumns. The value is in JSON object notation. Attributes are shown exactly as set usingCREATE USERandALTER USERstatements withATTRIBUTEorCOMMENToptions. A comment is shown as a key-value pair havingcommentas the key. For additional information and examples, see CREATE USER Comment and Attribute Options.
注意事项Notes
USER_ATTRIBUTES是一个非标准的INFORMATION_SCHEMA表。USER_ATTRIBUTESis a nonstandardINFORMATION_SCHEMAtable.要仅以未加引号的字符串形式获取指定用户的用户评论,可以使用如下查询:To obtain only the user comment for a given user as an unquoted string, you can employ a query such as this one:
mysql>
SELECT ATTRIBUTE->>"$.comment" AS Comment->FROM INFORMATION_SCHEMA.USER_ATTRIBUTES->WHERE USER='bill' AND HOST='localhost';+-----------+ | Comment | +-----------+ | A comment | +-----------+同样,你可以使用其键获取指定用户属性的未加引号值。Similarly, you can obtain the unquoted value for a given user attribute using its key.
USER_ATTRIBUTES的内容可以通过如下方式访问:USER_ATTRIBUTEScontents are accessible as follows:如果满足以下条件,可访问所有行:All rows are accessible if:
当前线程是副本线程。The current thread is a replica thread.
访问控制系统尚未初始化(例如,服务器是使用
--skip-grant-tables选项启动的)。The access control system has not been initialized (for example, the server was started with the--skip-grant-tablesoption).当前身份验证的帐户对
mysql.user系统表具有UPDATE或SELECT权限。The currently authenticated account has theUPDATEorSELECTprivilege for themysql.usersystem table.当前身份验证的帐户具有
CREATE USER和SYSTEM_USER权限。The currently authenticated account has theCREATE USERandSYSTEM_USERprivileges.
否则,当前认证的账户可以看到该账户的行。此外,如果该账户拥有
CREATE USER权限但没有SYSTEM_USER权限,它可以看到所有其他没有SYSTEM_USER权限账户的行。Otherwise, the currently authenticated account can see the row for that account. Additionally, if the account has theCREATE USERprivilege but not theSYSTEM_USERprivilege, it can see rows for all other accounts that do not have theSYSTEM_USERprivilege.
有关指定账户注释和属性的更多信息,请参见 第 15.7.1.3 节,“CREATE USER 语句”。For more information about specifying account comments and attributes, see Section 15.7.1.3, “CREATE USER Statement”.