In this blog post, we’ll look at MySQL 8 user attributes and how
we can use them.
What is the user attribute?
A user attribute is a JSON object made up of one or more
key-value pairs, and it is set while creating the user with
CREATE USER and by including ATTRIBUTE ‘json_object’. json_object
must be a valid JSON object (should be key-value pairs).
We all know MySQL stores all user-related data in mysql.user
table, but we don’t have any column to add any attributes for the
user. With this new feature of user attributes, we can actually
add some additional details as an attribute for the user, which
is pretty useful in getting some additional details of the user,
such as mobile number, job title, country, etc.
The user attribute feature is available from MySQL 8.0.21, and it
comes with a USER_ATTRIBUTES table from information_schema, which
provides information about the user comments and user attributes.
It …
[Read more]