How to Configure n8n MySQL Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up n8n mysql permissions by creating a dedicated database user with narrow table grants. Then you add those login keys to your n8n workflow nodes. Most teams start by sharing a broad admin account to get workflows running fast. Broad roles let automated tasks or AI agents read or alter every table by mistake. How n8n mysql permissions work in practice N8n connects to your database using static login keys stored inside the app. Every standard node or AI agent tool uses that same databa

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 n8n mysql permissions by creating a dedicated database user with narrow table grants. Then you add those login keys to your n8n workflow nodes. Most teams start by sharing a broad admin account to get workflows running fast. Broad roles let automated tasks or AI agents read or alter every table by mistake.

How n8n mysql permissions work in practice

N8n connects to your database using static login keys stored inside the app. Every standard node or AI agent tool uses that same database account when it runs. For AI workflows, you attach a MySQL tool sub-node to an AI Agent node. The AI Agent node uses a chat model and picks which tools to call.

Inside the database, the engine checks the user grants right when the session starts. You can limit the account to read-only queries on specific schemas or tables. You can also block table drops, schema changes, or row deletes at the database level. Once the user logs in, the database allows any query that matches those static grants.

Where static database grants fall short

Native database roles solve the first step of security by limiting who can log in. They stop an n8n workflow from touching tables outside its assigned schema. This works well for fixed workflows that run the exact same query every time.

Still, static grants cannot inspect what individual queries do while they run in flight. An AI agent converts natural language questions into SQL queries and runs them on its own. If the database user has read rights on a customer table, every column is open by default. Returned query results can expose emails, phone numbers, card numbers, or national IDs to the model.

Database roles also lack context about which person or prompt triggered the n8n workflow. Every query in the database log shows the same shared n8n service account name. If an agent runs a bad update query, you cannot pause it for human approval. Static grants decide who logs in, not how each statement behaves at run time.

MySQL Access Governance + AI Agent Permissions: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

How to scope database roles for automation

Start by creating a separate MySQL user for each n8n workflow or agent task. Never reuse your main app database user or root account for workflow automation. Grant only read rights on the exact tables the workflow needs to read.

If a workflow must write data, restrict insert or update rights to specific columns. Keep sensitive tables out of the schema grants whenever you build AI agent tools. Even with tight grants, you still need a way to mask sensitive fields in results. Masking rewrites matched fields like emails or card numbers before the workflow uses them.

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 should I set up MySQL for an n8n AI Agent node?

Use a MySQL tool sub-node attached to a current n8n AI Agent node. Give that sub-node a dedicated database user that only has read rights on safe tables.

N8n deprecated the standalone agent type setting starting in version 1.82.0. All AI Agent nodes now work as Tools Agents using attached MySQL tool sub-nodes.

Can native MySQL roles hide sensitive columns in query results?

MySQL can block a user from querying a column, which causes the query to fail. To return the row with masked emails or phone numbers, you need runtime data masking.

The query runs. The emails stay hidden.