How to Configure n8n MySQL Sandbox
You set up an n8n mysql sandbox by creating an isolated database and linking a restricted user to your workflow. This setup lets automated jobs and AI agents run queries without putting main tables at risk. Teams often start by reusing a broad admin account during testing. That shortcut gives every workflow node full read and write power over the whole database. If a job fails or an agent makes a bad query, it can break live tables. How to set up an n8n mysql sandbox architecture A safe setup
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 mysql sandbox by creating an isolated database and linking a restricted user to your workflow. This setup lets automated jobs and AI agents run queries without putting main tables at risk. Teams often start by reusing a broad admin account during testing. That shortcut gives every workflow node full read and write power over the whole database. If a job fails or an agent makes a bad query, it can break live tables.
How to set up an n8n mysql sandbox architecture
A safe setup starts inside the database server itself. You create a separate test schema or a stand-alone database instance filled with fake records. Next, you create a dedicated database user just for the workflow app. You grant this user permission only on the tables it needs to read or change. You then save those login keys inside the workflow tool credential store.
When you build AI workflows, the n8n AI Agent node pairs a chat model with one or more tool sub-nodes. You must attach at least one tool sub-node so the agent can act. The agent decides which tools to call to finish its task. From n8n 1.82.0 onward, the old agent type setting is deprecated, and all AI Agent nodes work as a Tools Agent. Node version 1 is removed in n8n 3.0. For database tasks, the docs advises using a MySQL tool sub-node with a recent Agent node instead of the old SQL Agent.
What native database roles solve and what they miss
Native database roles and separate test instances solve the basic login problem. They decide which user account can log in and which schemas that account can touch. If you revoke write rules on the account, the workflow cannot drop tables or delete rows. Using a separate test instance also stops heavy test queries from slowing down your live database.
Still, static database permissions leave a large runtime gap open. Database roles check who logs in at the start of a session. They do not inspect what individual statements do while queries run in flight. Every workflow node that shares the stored credential gets the exact same table permissions. If a test database holds real customer emails, phone numbers, card numbers, or national IDs, any allowed select query returns those raw values to the chat model. Static roles also cannot demand human review before an agent runs a sensitive update statement.
MySQL Access Governance + AI Sandbox Environments: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Why agent workflows need statement-level controls
AI agents write and run their own queries based on user prompts. Even inside a test database, an agent can write a bad join that locks tables. It can also pull thousands of rows containing sensitive fields into workflow logs. Teams need a way to inspect each query after the agent builds it. They also need a way to rewrite matched fields like emails or card numbers in results before data reaches the model. Adding runtime checks closes the gap between basic login rules and actual query execution.
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 MySQL?
Attach a MySQL tool sub-node directly to a recent AI Agent node in your workflow. The agent uses your saved database login to run queries when the chat model needs data.
Should I still use the n8n SQL Agent mode for MySQL?
No, the old agent type setting is deprecated starting in n8n 1.82.0 and removed in 3.0. You should use a recent AI Agent node working as a Tools Agent with a MySQL tool sub-node.
Why is a read-only MySQL user not enough for a sandbox?
A read-only user still lets workflows read every row and column inside allowed tables by default. If the sandbox holds copied production records, queries can still expose emails, phone numbers, or card numbers to logs and models.
Related guides
In this post