How to Configure n8n MariaDB Audit Log
You set up an n8n mariadb audit log by turning on database logging and linking a database tool. The database then records every login and SQL query from your workflow. Teams often build workflows where an AI agent reads or writes database rows. Many teams give that workflow one shared database account with broad permissions. If an agent runs a bad query, broad permissions make the damage much worse. How an n8n mariadb audit log works in workflow runs In n8n, the AI Agent node pairs a chat mod
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.
You set up an n8n mariadb audit log by turning on database logging and linking a database tool. The database then records every login and SQL query from your workflow. Teams often build workflows where an AI agent reads or writes database rows. Many teams give that workflow one shared database account with broad permissions. If an agent runs a bad query, broad permissions make the damage much worse.
How an n8n mariadb audit log works in workflow runs
In n8n, the AI Agent node pairs a chat model with one or more tools. The agent picks which tools to call so it can finish a task. You must attach at least one tool sub-node to the AI Agent node. Starting in n8n 1.82.0, the old agent type setting is deprecated. Every AI Agent node now works as a Tools Agent. Node version 1 is removed in n8n 3.0. For SQL tasks, the docs tell you to attach a MySQL or Postgres tool sub-node. MariaDB uses the MySQL wire protocol, so teams use this path for MariaDB too.
The deprecated SQL Agent could turn plain text questions into SQL queries and run them. Now, a recent AI Agent node with a database tool sub-node handles this job. Besides built-in nodes, n8n has a registry of MCP servers and a Custom Code Tool. You can also attach a Call n8n Workflow Tool or an HTTP Request Tool. When the agent runs a query, the database log writes down the event. It records the database user, the time, and the SQL text. Your security team can read these log files later to check what happened.
What native database logs solve and what they miss
A native database log is great for checking past events after a run finishes. It proves which database user logged in and what SQL statements ran on the server. It also helps teams spot failed login attempts or strange query spikes over time. If a table breaks, you can read the log to find the bad statement.
Still, a native database log only records events after they happen. It cannot stop a dangerous query while the query is in flight. Also, every n8n workflow run usually shares the same static database login key. In the database log, every query looks like it came from that one shared user. You cannot easily tell which workflow user or prompt caused a specific query. Even worse, native logs do not mask sensitive data in query results. If an agent reads a table, raw emails, phone numbers, or card numbers flow back. Static database roles only decide who can log in at the start. They do not inspect individual queries or rewrite sensitive fields in results.
Audit Log Integrity + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Why agent workflows need runtime query controls
AI agents write and pick their own queries based on user input. A small change in a prompt can make an agent ask for way too much data. Relying on a shared database role leaves production tables open to mistakes. Teams need a way to check every statement before the database runs it. They also need a way to mask national IDs or card numbers in results. Finally, logs should tie each query back to the real person or workflow run.
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. It runs next to MySQL, RDS, or Aurora and reads the MySQL wire protocol.
Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails. When a rule refuses a query, MySQL returns a native error packet with your message. On the response path, hoop.dev data masking rewrites string values in returned rows that match your rules. Every query and decision is logged per resource. See the MIT-licensed project on GitHub.
Frequently asked questions
How do I connect an n8n AI agent to a MariaDB database?
Attach a MySQL tool sub-node to a recent AI Agent node in your workflow. Since n8n 1.82.0, all AI Agent nodes run as a Tools Agent and replace the SQL Agent.
Does the MariaDB log show which n8n user ran a query?
No, the native database log only sees the database account stored in your n8n credentials. All workflow runs using that credential show up under the same database username.
Can native database audit logs hide PII from AI agents?
No, a database audit log only writes activity to a file for later review. It does not rewrite matched fields like emails or phone numbers in query results.
Related guides
In this post