How to Configure Amazon Q MySQL Audit Log

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up an amazon q mysql audit log, turn on database auditing and track agent logins. You must also tie each query back to the human who started the task. Teams often let AI coding agents use shared database logins or local developer keys. When permissions are too broad, the agent can read or change any table in the database. Shared roles also make it hard to see which person ran a specific query. How the native amazon q mysql audit log workflow operates Amazon Q Developer runs as an AI co

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.

To set up an amazon q mysql audit log, turn on database auditing and track agent logins. You must also tie each query back to the human who started the task. Teams often let AI coding agents use shared database logins or local developer keys. When permissions are too broad, the agent can read or change any table in the database. Shared roles also make it hard to see which person ran a specific query.

How the native amazon q mysql audit log workflow operates

Amazon Q Developer runs as an AI coding agent inside your editor or terminal. The agent can run shell commands and reach outside systems using the developer's local settings. When the agent needs database facts, it connects to MySQL using local keys or roles. MySQL then checks the login details and lets the session start.

On the database side, the native audit plugin watches and records server activity. You can set up the database to log login events, table reads, and data changes. Each log entry captures the database user name, the timestamp, and the raw SQL text. The database writes these records to a local file or sends them to a log collector.

Security teams then read these files to check what the AI agent did during a session. To tell agent queries apart from human queries, teams often make a separate MySQL role. They give that specific role to the coding agent setup on each developer machine. Every query from that role then shows up under the agent's name in the log.

What native logging solves and the operational gap it leaves open

Native database logging gives you a basic record of past queries and login events. It proves that a specific database role ran a command at a certain time. This helps teams spot broken queries or find out which table changed after an incident. It also shows when a user fails to log in due to bad keys.

Still, native database setup only decides who can log in at the start. It does not check or pause risky SQL statements while they are in flight. If a developer has broad write permissions, the AI agent gets those same broad rights. The native audit log records a bad delete command only after the data is gone.

Static database roles also hide which person asked the agent to run a query. If five engineers share one agent role, the log shows one user name for all of them. You cannot trace a bad change back to a single person without checking local laptops.

Audit Log Integrity + MySQL Access Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Why query-level controls matter for AI agents

AI coding agents work fast and can run dozens of SQL statements in seconds. They often read schema details and sample rows to write or fix app code. When sample rows hold real user data, those values enter the agent's context window. Native audit logs record the read query, but they do not change the returned data.

Data masking fixes this by rewriting matched fields in query results before they reach the client. For example, masking can replace emails, phone numbers, card numbers, or national IDs with placeholders. The coding agent still sees the table structure and data types it needs to work. At the same time, raw personal details stay inside the database instead of reaching the prompt.

Teams also need a way to stop destructive commands before the database runs them. Waiting for an engineer to read an audit file the next day is too late. Real-time checks let teams block drop statements or require human approval for data updates.

Check MySQL queries and results on the wire

MySQL grants control who logs in. They do not check single queries or mask sensitive columns once a session starts. With hoop.dev, you run an open-source proxy, a sidecar for your MySQL, inline in the MySQL wire protocol. On every query an AI agent or human runs against production MySQL, RDS, or Aurora, hoop.dev decides to pass, mask, block, or hold it for review.

Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails, which refuse banned queries with a native MySQL error or hold risky ones for approval. On the response path, hoop.dev data masking rewrites string values in returned rows in memory, and every decision is logged. See the MIT-licensed project on GitHub.

Frequently asked questions

Can MySQL audit logs tell if a query came from Amazon Q or a human?

MySQL only logs the database user account that opened the session. If the agent uses the developer's own login, the log looks identical for both. You must assign a separate identity or capture client metadata to tell them apart.

Does turning on the MySQL audit log block an AI agent from dropping tables?

No, an audit log only records events as they happen on the server. It cannot block or pause a command. To stop destructive queries, you must restrict the database role or inspect statements before execution.

How can teams protect sensitive columns when Amazon Q inspects a database?

Audit logs do not hide data in query results. Teams can use dynamic data masking to rewrite emails, phone numbers, and card numbers in transit. This lets the agent inspect schemas and sample rows while masking personal fields.

The query runs. The emails stay hidden.