Audit Related: Which Table or Monitoring Page in TiDB Records the User's Last Login Time

This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 审计相关:tidb哪个表或者监控页面记录了user最后登陆时间

| username: ShawnYan

As mentioned, where is the user’s last login time and the last password change time recorded?

| username: wangccsy | Original post link

This is a MySQL query method, you can refer to it.

| username: ShawnYan | Original post link

Which version of MySQL and what is the table structure like?

| username: dba远航 | Original post link

user_logins, the specific version is related to the underlying MySQL version.

| username: 有猫万事足 | Original post link

In TiDB 7.5, you can still check the last password change time using the query above, but I couldn’t find the last login time.

| username: yulei7633 | Original post link

Did not find the related table.

| username: 连连看db | Original post link

You can check the log page, this might be able to filter it out.

| username: zhanggame1 | Original post link

There is no last login time.

| username: redgame | Original post link

We haven’t found this either.

| username: cassblanca | Original post link

TiDB doesn’t have this feature for now, but there might be a workaround. You can enable the audit plugin and analyze the audit logs. Alternatively, using middleware like TiDB Proxy should record the user’s connection and disconnection times.

| username: 啦啦啦啦啦 | Original post link

Which version of MySQL has the user_logins table?

| username: 胡杨树旁 | Original post link

mysql.user has a record of the last modification time, but there is no record of the last login time.

| username: 连连看db | Original post link

What the heck, isn’t this the password change time? It has nothing to do with whether the user logs in or not.

| username: TIDB-Learner | Original post link

The community edition cannot be queried directly, but you can enable logging and then query. The enterprise edition should be able to.