简体   繁体   中英

mysql user last login / access date time

During in a audit task, I am going to delete few mysql users. Before delete I want to check, when the last time these user access the database server. I want to know if we have this information stored in information_schema or mysql databases. If not how can we achieve this?

You can look in the general log for any unsuccessful connection attempts to MySQL however out-of-the-box, MySQL typically does not log successful DB connections. This could become a very, very large log and that activity may quickly overwhelm the I/O subsystem and cause problems for the DB.

You can setup this sort of logging however it will result in quite a LOT of data! have a look at this post over in the DBA Exchange: https://dba.stackexchange.com/questions/668/audit-logins-on-mysql-database

If you are using a DB server that is yours and yours alone, you should be able to do this. If you have a DBaaS type thing, multi-tenant DB systems would die logging each connect. This may not be possible?

You may also find some steps on enabling usertracking in MySQL from the Percona blog: https://www.percona.com/blog/2012/12/28/auditing-login-attempts-in-mysql/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM