MySQL Audit_log_policy
The mysql audit_log_policy setting controls which database events your server writes to its audit file. You can tell the server to record all actions, only log in events, or queries. Database admins use this rule to balance disk space against security needs. Recording every single read and write action creates huge log files fast. Turning off query logs saves space, but it leaves teams blind to bad queries. How mysql audit_log_policy works in practice When you turn on the audit plugin, the s
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
The mysql audit_log_policy setting controls which database events your server writes to its audit file. You can tell the server to record all actions, only log in events, or queries.
Database admins use this rule to balance disk space against security needs. Recording every single read and write action creates huge log files fast. Turning off query logs saves space, but it leaves teams blind to bad queries.
How mysql audit_log_policy works in practice
When you turn on the audit plugin, the server checks every user action. It compares each action against your active policy rule before writing to the disk. If you pick the all option, the engine logs every login and every query. If you pick the logins option, it only records when users connect or fail.
You can also tell the server to log only queries and skip login events. Or you can disable logging for a short time without removing the plugin. Both human engineers and AI agents trigger these exact same checks when they run queries. The database does not care if a person or a script sends the command.
The audit engine sits inside the database server process itself. Every time a query runs, the server must pause to format and write the event. High traffic apps can slow down if the disk cannot keep up with the logs. Teams often ship these files to an outside log store for review later.
Security tradeoffs of native database audit logs
Native audit rules only record what happened after the query finishes running. They do not stop a bad command from dropping a table or reading secrets. Static database roles and shared keys create another big blind spot for security teams. Many apps and engineers log in using the exact same database user name.
When five developers share one role, the audit file shows one generic user name. You can see the bad query, but you cannot see who ran it. AI agents and automated scripts make this problem much worse when they share keys. You lose the link between a real person and the query they ran.
Audit Log Integrity + MySQL Access Governance: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Native audit policies also lack fine controls over the data returned inside an active session. If an engineer queries a customer table, the server returns raw emails and card numbers. The audit log records that the query ran, yet the raw data still leaves. Native logs can also expose phone numbers or national IDs inside the query text itself.
Why query-level controls matter for modern teams
Relying only on server settings means you must configure every database host by hand. If you run dozens of MySQL instances, keeping those rules in sync takes real work. A local admin with high permissions can also change the policy and hide their tracks. Moving audit and policy checks outside the database fixes this gap.
When a central layer sits in front of the database, it checks identity first. Every engineer and AI agent logs in with their own work identity. The system maps each query to a real person before it hits the server. You get a clean log of every action across all databases in one place.
You can also apply data masking on the fly as query results come back. Masking rewrites matched fields in results, such as card numbers, emails, and phone numbers. Engineers can fix bugs using real tables while sensitive fields get replaced in the output. You get full query visibility without putting extra disk load on your database host.
Inspect every MySQL query and response in flight
Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev sits inline in the MySQL protocol as a sidecar for your MySQL. For every plain query, prepared statement, or cursor an agent or human runs in production, hoop.dev decides to pass, mask, block, or hold it for review.
First, hoop.dev guardrails block banned actions before MySQL runs them, and an AI Analyzer you configure can score intent or escalate for approval. Next, hoop.dev data masking rewrites sensitive string columns in results in memory, and every verdict goes to the audit trail. Find the open-source binary on GitHub.
Frequently asked questions
What are the main options for mysql audit_log_policy?
You can set the policy to log all events, only logins, only queries, or nothing. Most teams pick between logging all activity or logging only login events to save disk space.
Does turning on query logging slow down the database?
Yes, logging every query adds disk write work and CPU load to the database server. Busy databases can face slowdowns if the local disk cannot write log files fast enough.
Can the native audit plugin mask sensitive data in query results?
No, the native audit plugin only writes past events to a log file. To rewrite emails, phone numbers, or card numbers in results, you need a data masking layer.
Related guides
In this post