USER_ATTRIBUTES

The USER_PRIVILEGES table provides information about user comments and user attributes. This information comes from the mysql.user system table.

  1. USE information_schema;
  2. DESC user_attributes;
  1. +-----------+--------------+------+------+---------+-------+
  2. | Field | Type | Null | Key | Default | Extra |
  3. +-----------+--------------+------+------+---------+-------+
  4. | USER | varchar(32) | NO | | NULL | |
  5. | HOST | varchar(255) | NO | | NULL | |
  6. | ATTRIBUTE | longtext | YES | | NULL | |
  7. +-----------+--------------+------+------+---------+-------+
  8. 3 rows in set (0.00 sec)

Fields in the USER_ATTRIBUTES table are described as follows:

  • USER: The user name.
  • HOST: The host from which the user can connect to TiDB. If the value of this field is , it means that the user can connect to TiDB from any host.
  • ATTRIBUTE: The comment and attribute of the user, which are set by the CREATE USER or ALTER USER statement.

The following is an example:

  1. CREATE USER testuser1 COMMENT 'This user is created only for test';
  2. CREATE USER testuser2 ATTRIBUTE '{"email": "user@pingcap.com"}';
  3. SELECT * FROM information_schema.user_attributes;
  1. +-----------+------+---------------------------------------------------+
  2. | USER | HOST | ATTRIBUTE |
  3. +-----------+------+---------------------------------------------------+
  4. | root | % | NULL |
  5. | testuser1 | % | {"comment": "This user is created only for test"} |
  6. | testuser2 | % | {"email": "user@pingcap.com"} |
  7. +-----------+------+---------------------------------------------------+
  8. 3 rows in set (0.00 sec)