AUDIT ACCESS configures MySQL’s enterprise-grade audit plugin to log connections, queries, and privilege use for later security review.
Auditing exposes who connected, what queries ran, and which rows changed. Security teams use these logs to detect abuse, satisfy compliance, and debug data issues.
Install the built-in audit_log
plugin, reload the server, then pick a logging policy.No schema changes are required.
See the syntax block below for INSTALL PLUGIN
, policy variables, and filter creation.
Set audit_log_policy = 'ALL'
. MySQL writes each connection, disconnection, and statement to $DATADIR/audit.log
.
Create a JSON filter that includes only the Customers
, Orders
, and Products
tables.Attach the filter to specific users to reduce noise.
Use mysqlbinlog --read-from-remote-server --raw --result-file=./ audit.log
or stream it into any SIEM that understands JSON.
Rotate daily or whenever the file reaches 100 MB. Use SET GLOBAL audit_log_rotate_now = ON
to force an immediate roll-over.
Store logs on a separate volume, ship them off-box hourly, and hash each rotated file.Never place audit logs on tmpfs.
Switch to audit_log_policy = 'LOGINS,TABLE_ACCESS'
or add a filter that excludes high-volume read-only traffic.
First set the policy to 'NONE'
, verify the log has stopped, then UNINSTALL PLUGIN audit_log
during a maintenance window.
The example query shows how to filter UPDATEs to the Customers.email
column and link each change to the modifying user.
Automate log shipping, build Grafana dashboards, and alert on suspicious patterns such as mass DELETE
operations.
.
Yes, the JSON filter syntax and real-time rotation are Enterprise features. Community users can rely on the general log instead.
Absolutely. Use tail -F
or fluentbit
to stream audit.log
to your preferred observability stack.
Create a JSON filter whose object
section matches {"db":"ecom","name":"Orders"}
and attach it to the relevant roles.