How to Configure n8n MariaDB Sandbox
You set up an n8n mariadb sandbox by linking an AI Agent node to a database tool sub-node. This setup uses a locked-down test database role with strict table grants. Teams often start by giving the workflow full admin credentials to save time. That choice lets the agent read sensitive test data or drop tables by mistake. A safer design uses an isolated database instance and a dedicated read-only user. How to set up an n8n mariadb sandbox architecture 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 sandbox by linking an AI Agent node to a database tool sub-node. This setup uses a locked-down test database role with strict table grants. Teams often start by giving the workflow full admin credentials to save time. That choice lets the agent read sensitive test data or drop tables by mistake. A safer design uses an isolated database instance and a dedicated read-only user.
How to set up an n8n mariadb sandbox architecture
In n8n, the AI Agent node pairs a chat model with one or more tool sub-nodes. The agent reads the user prompt and decides which tools to call to finish the task. Every AI Agent node needs at least one attached tool sub-node to work. From n8n version 1.82.0 onward, all AI Agent nodes operate as a Tools Agent. The older agent type setting is deprecated, and version 3.0 removes the old node version. For database tasks, n8n docs recommend attaching a MySQL or Postgres tool sub-node to a recent Agent node. Because MariaDB uses the MySQL wire protocol, teams use the MySQL tool sub-node to reach MariaDB.
You can also attach a Call n8n Workflow Tool or a Custom Code Tool. Some teams use an HTTP Request Tool or MCP server registry tools instead. Inside your test database, you create a separate schema with fake records. Next, you create a MariaDB user account that only has permissions on that test schema. You put those user credentials into the n8n credential store for the database sub-node. When the workflow runs, the agent turns natural language questions into SQL queries and runs them.
What native database roles solve and what they leave open
Native MariaDB grants decide which user account can log in and which tables it can touch. If you limit the account to select queries, the agent cannot delete rows or drop tables. You can also limit which tables the tool sees inside the workflow setup. This blocks the agent from touching production schemas if the sandbox sits on a shared host.
Still, static database roles only check who logs in at the start of a session. They do not inspect what individual queries do while they run in flight. An agent with read permissions on a test table can still pull thousands of rows at once. If a developer copies real customer records into the sandbox, the agent reads them all. Standard database roles cannot rewrite matched fields like emails, phone numbers, or card numbers in query results. They also cannot pause a risky query to ask a human for approval before it runs. Finally, database logs only show the shared n8n user account, not which workflow run triggered the query.
AI Sandbox Environments + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Why shared test databases still need statement-level controls
Teams rarely keep a sandbox clean forever. Engineers often load database dumps from staging or production to debug tricky app bugs. Those dumps frequently contain real national IDs, emails, or phone numbers. When an AI agent runs a broad query, those fields flow straight to the external chat model. Static roles in MariaDB are all-or-nothing at the table or column level. If the agent needs a table to answer questions, it gets every row in that table. Without runtime query checks and result masking, test workflows can still leak sensitive data to third-party model providers.
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
Which n8n node should I use to query a MariaDB sandbox?
Use a recent AI Agent node and attach a MySQL tool sub-node to it. From n8n 1.82.0, all AI Agent nodes work as a Tools Agent and replace the old SQL Agent.
Why is a read-only MariaDB user not enough for an AI sandbox?
A read-only user stops writes, but the agent can still run huge queries or read sensitive rows. Native roles cannot rewrite emails or card numbers in results before they reach the chat model.
How do I stop an n8n agent from querying the wrong tables?
Create a dedicated MariaDB user that only has select grants on your specific sandbox tables. You can also restrict which tables the database tool sub-node exposes to the agent.
Related guides
In this post