We have several MySQL 5.0 databases.

We've been having security problems, like records being modified without authorization.

We need to implement some kind of audit on DML operations identifying users that perform UPDATE or DELETE operations on some critical tables.

I have been googling about any my.conf options that would activate this kind of audits, to no avail.

up vote 1 down vote accepted

The least disruptive method would be to use the general query log. The query log output can be a database table or a log (text) file; however it does not support filtering by DML operation or database so all SELECT statements on all databases will be logged as well. Obviously you can filter the logging output later.

Also note:

The session sql_log_off variable can be set to ON or OFF to disable or enable general query logging for the current connection.

This means that with some injected logic, you could conceivably disable logging for SELECTs.

Another solution is to use triggers on UPDATE, INSERT, DELETE. This will directly affect the database in question but not other databases running in the same instance.

See also SO questions here and here.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.