Documentation Home
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 48.0Mb
PDF (A4) - 48.0Mb
PDF (RPM) - 43.7Mb
HTML Download (TGZ) - 11.1Mb
HTML Download (Zip) - 11.1Mb
HTML Download (RPM) - 9.6Mb
Man Pages (TGZ) - 238.8Kb
Man Pages (Zip) - 342.4Kb
Info (Gzip) - 4.3Mb
Info (Zip) - 4.3Mb
Excerpts from this Manual

MySQL 8.0 Reference Manual  /  INFORMATION_SCHEMA Tables  /  The INFORMATION_SCHEMA USER_ATTRIBUTES Table

25.42 The INFORMATION_SCHEMA USER_ATTRIBUTES Table

The USER_ATTRIBUTES table provides information about user comments and user attributes. It takes its values from the mysql.user system table.

The USER_ATTRIBUTES table has the following columns:

  • USER

    The user name portion of the account name to which the comment, attribute, or both belong.

  • HOST

    The host name portion of the account name.

  • ATTRIBUTE

    The user comment, user attribute, or both belonging to the user specified by the user and host shown in the previous two columns, in JSON object notation. Attributes are shown exactly as set using CREATE USER ... ATTRIBUTE ... or ALTER USER ... ATTRIBUTE ...; the user comment is shown as a key-value pair having comment as the key.

    For example, the statement CREATE USER 'bill'@'localhost' COMMENT 'A comment' ATTRIBUTE '{"foo": "bar", "bazz": "fazz"}' adds the following row to the USER_ATTRIBUTES table:

    +------+-----------+--------------------------------------------------------+
    | USER | HOST      | ATTRIBUTE                                              |
    +------+-----------+--------------------------------------------------------+
    | bill | localhost | {"foo": "bar", "bazz": "fazz", "comment": "A comment"} |
    +------+-----------+--------------------------------------------------------+

Notes

  • 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.

  • The USER_ATTRIBUTES table was added in MySQL 8.0.21.

For more information, see Section 13.7.1.3, “CREATE USER Statement”.