We all know that the meta data of user in MySQL is stored in the Mysql.user table, but unfortunately there is less information available, such as we don't know the exact creation time of a certain user.
We can use the following method to achieve this goal.
First, we add a column to the Mysql.user table that is used to record the creation time of the user and give the default value.
Mysql> ALTER TABLE Mysql.user add create_time timestamp default current_timestamp; Query OK, 9 rows affected (0.06 sec) records:9 duplicates:0 warnings:0
At this point, we can do a test.
Mysql> create user wison_test identified by ' wisontest '; Query OK, 0 rows Affected (0.00 sec)
Below, we can see the creation time of the user.
Mysql> Select Host,user,password,create_time from Mysql.user where user= ' wison_test '; +------+------------+-- -----------------------------------------+---------------------+| Host | User | password | create_time |+------+------------+-------------------------------------------+---- -----------------+| % | wison_test | *49b26a9583639e227274a403f369ae54a4061bab | 2014-12-25 17:13:17 |+------+------------+---------- ---------------------------------+---------------------+1 row in Set (0.00 sec)
Of course, the new column needs to be added when MySQL is in normal use. If added later, the value of the column create_time of the newly created user is 0000-00-00 00:00:00
How to record a user-created date in MySQL