Documentation Home
MySQL 9.2 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 40.8Mb
PDF (A4) - 40.9Mb
Man Pages (TGZ) - 259.7Kb
Man Pages (Zip) - 366.9Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb


MySQL 9.2 Reference Manual  / ...  / INFORMATION_SCHEMA Tables  / INFORMATION_SCHEMA General Tables  /  The INFORMATION_SCHEMA USER_ATTRIBUTES Table

28.3.47 The INFORMATION_SCHEMA USER_ATTRIBUTES Table

TheUSER_ATTRIBUTES table provides information about user comments and user attributes. It takes its values from themysql.user system table.

TheUSER_ATTRIBUTES table has these columns:

  • USER

    The user name portion of the account to which theATTRIBUTE column value applies.

  • HOST

    The host name portion of the account to which theATTRIBUTE column value applies.

  • ATTRIBUTE

    The user comment, user attribute, or both belonging to the account specified by theUSER andHOST columns. The value is in JSON object notation. Attributes are shown exactly as set usingCREATE USER andALTER USER statements withATTRIBUTE orCOMMENT options. A comment is shown as a key-value pair havingcomment as the key. For additional information and examples, seeCREATE USER Comment and Attribute Options.

Notes

  • USER_ATTRIBUTES is a nonstandardINFORMATION_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 contents are accessible as follows:

    • All rows are accessible if:

      • The current thread is a replica thread.

      • The access control system has not been initialized (for example, the server was started with the--skip-grant-tables option).

      • The currently authenticated account has theUPDATE orSELECT privilege for themysql.user system table.

      • The currently authenticated account has theCREATE USER andSYSTEM_USER privileges.

    • Otherwise, the currently authenticated account can see the row for that account. Additionally, if the account has theCREATE USER privilege but not theSYSTEM_USER privilege, it can see rows for all other accounts that do not have theSYSTEM_USER privilege.

For more information about specifying account comments and attributes, seeSection 15.7.1.3, “CREATE USER Statement”.