# Track user&date service use - MySQL 8.0

**URL:** <https://forums.percona.com/t/track-user-date-service-use-mysql-8-0/33061>\
**Category:** Percona Server for MySQL\
**Created:** [September 11, 2024, 9:17am UTC](https://forums.percona.com/t/track-user-date-service-use-mysql-8-0/33061 "2024-09-11T09:17:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahalachmi](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@ahalachmi](https://forums.percona.com/u/ahalachmi)\
**Post date:** [September 11, 2024, 9:17am UTC](https://forums.percona.com/t/track-user-date-service-use-mysql-8-0/33061/1 "2024-09-11T09:17:11Z")

</div>

Hi everyone,

Apologies if I missed any related discussions on this topic.

We use machines running MySQL services, and I want to track user logins to delete users who haven’t connected in the last 180 days .

I thought of creating a table with `user_name` and `last_login_date`. When a user connects to the service, it would check if the user exists; if they do, it updates the date; if not, it adds a new entry.

I’ve encountered some issues:

- Using audit logs overwhelms my logs, and cleaning them up doesn’t solve the problem.
- Filtering the logs didn’t help.
- Using triggers didn’t work, as we have multiple databases and a large number of connections.

Do you have any suggestions? Does Percona have a tool that could help with this?

Tnx in advance !!

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [September 11, 2024, 3:45pm UTC](https://forums.percona.com/t/track-user-date-service-use-mysql-8-0/33061/2 "2024-09-11T15:45:54Z")

</div>

The audit log is the only way you can track login/disconnect in MySQL. You say filtering didn’t help, but what filtering did you try? I would set this filter:

`SET GLOBAL audit_log_include_commands= 'set_option';`

This limits the log entries to only login, logout, and if any user runs `SET ...` which should drastically reduce your log entries.

---

<div class="post-metadata">

**Author:** ![ahalachmi](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@ahalachmi](https://forums.percona.com/u/ahalachmi)\
**Post date:** [September 12, 2024, 7:59am UTC](https://forums.percona.com/t/track-user-date-service-use-mysql-8-0/33061/3 "2024-09-12T07:59:40Z")

</div>

Thank you for the quick replay !  
I did ‘exclude’ for a lot commands - set\_connection among them  
I will try it !
