0

I want to log any queries dev's manually run against a MYSQL database instance. The application queries are not required to be logged.

The purpose behind this is to track and audit any custom queries that are run against production environments for tracking purposes. Just in case a query causes issue OR if we want to run the same query again we have a record of the query.

any ideas? (thanks for reading this far) :)

1 Answer 1

0

It sounds like you want to use an audit log plugin. The MySQL Enterprise Audit has an option to filter by username. See https://dev.mysql.com/doc/refman/8.0/en/audit-log-filtering.html But a possible disadvantage of the MySQL Enterprise Audit plugin is that you need to pay for a support contract to get a license to use it.

There are a few open-source alternative implementations of the MySQL Audit Log plugin, but I don't know if they have equivalent filtering features.

If you want to rely on query logs, you could try the following:

  • Enable the query log globally
  • Code your application to disable query logging in its session immediately after connecting

That way all developers' sessions will default to logging queries, but the app won't.

The weakness in this strategy is that any developer can turn off query logging in their own session. There's no way to prevent a MySQL user from changing options in their own session.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.