I am trying to set up auditing for changes to data in MySQL tables, for my Perl web application. I've had a look at this:
and that looks good because it uses triggers to automatically create the audit records, but it looks as if it will record the MySQL user (e.g. USER() or CURRENT_USER()) in the audit table record, and since my application uses the same MySQL user for all web users, this won't identify the actual person who is making the change. In my application, the ID of the person making the change is stored in a Perl variable (say $userid, which is an integer).
So, without me having to do extra coding wherever I make changes to tables (presumably by using triggers), how can I get MySQL to audit all changes to my tables, recording the $userid (Perl variable) as the user who made the change?
I've also had a quick look at these, but haven't recognised a solution to this $userid problem yet:
- mysql: Ver 14.14 Distrib 5.5.40, for Linux (x86_64) using readline 5.1
- Perl: 5.10.1