文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 28 个 INFORMATION_SCHEMA 表 / 28.3 INFORMATION_SCHEMA 总表 / 28.3.45 INFORMATION_SCHEMA USER_ATTRIBUTES 表
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 95%

28.3.45 INFORMATION_SCHEMA USER_ATTRIBUTES 表28.3.45 The INFORMATION_SCHEMA USER_ATTRIBUTES Table

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 the ATTRIBUTE column value applies.

  • HOSTHOST

    应用于 ATTRIBUTE 列值的账户的主机名部分。The host name portion of the account to which the ATTRIBUTE column 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 the USER and HOST columns. The value is in JSON object notation. Attributes are shown exactly as set using CREATE USER and ALTER USER statements with ATTRIBUTE or COMMENT options. A comment is shown as a key-value pair having comment as the key. For additional information and examples, see CREATE USER Comment and Attribute Options.

注意事项Notes

  • USER_ATTRIBUTES 是一个非标准的 INFORMATION_SCHEMA 表。USER_ATTRIBUTES is a nonstandard INFORMATION_SCHEMA table.

  • 要仅以未加引号的字符串形式获取指定用户的用户评论,可以使用如下查询: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_ATTRIBUTES contents 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-tables option).

      • 当前身份验证的帐户对 mysql.user 系统表具有 UPDATE 或 SELECT 权限。The currently authenticated account has the UPDATE or SELECT privilege for the mysql.user system table.

      • 当前身份验证的帐户具有 CREATE USER 和 SYSTEM_USER 权限。The currently authenticated account has the CREATE USER and SYSTEM_USER privileges.

    • 否则,当前认证的账户可以看到该账户的行。此外,如果该账户拥有 CREATE USER 权限但没有 SYSTEM_USER 权限,它可以看到所有其他没有 SYSTEM_USER 权限账户的行。Otherwise, the currently authenticated account can see the row for that account. Additionally, if the account has the CREATE USER privilege but not the SYSTEM_USER privilege, it can see rows for all other accounts that do not have the SYSTEM_USER privilege.

有关指定账户注释和属性的更多信息,请参见 第 15.7.1.3 节,“CREATE USER 语句”。For more information about specifying account comments and attributes, see Section 15.7.1.3, “CREATE USER Statement”.