How to Configure n8n MariaDB Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up n8n mariadb permissions by creating a dedicated database user with strict table rights. Then you save those login keys inside your n8n account for workflows to use. Many teams start by reusing an admin database account to get workflows running fast. That broad role lets a broken workflow or AI agent change or delete production tables. How n8n mariadb permissions work in practice N8n connects to MariaDB through standard database nodes or through AI Agent tool sub-nodes. The n8n AI A

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 mariadb permissions by creating a dedicated database user with strict table rights. Then you save those login keys inside your n8n account for workflows to use. Many teams start by reusing an admin database account to get workflows running fast. That broad role lets a broken workflow or AI agent change or delete production tables.

How n8n mariadb permissions work in practice

N8n connects to MariaDB through standard database nodes or through AI Agent tool sub-nodes. The n8n AI Agent node pairs a chat model with one or more connected tools. The agent decides which tool to call to finish a task on its own. For database tasks, teams attach a compatible SQL tool sub-node to a recent Agent node. You must connect at least one tool sub-node when you build an AI Agent node. You can also wire a database node inside a child workflow and call it.

On the MariaDB side, admins create a specific user account just for the n8n server. They grant that account only the exact read or write rights each workflow needs. A reporting workflow only needs select rights on specific views or summary tables. An ingestion job needs insert or update rights on a narrow set of staging tables. Keeping read and write logins separate stops a read workflow from altering live records. You also restrict the account host so only the n8n server address can log in.

What native database roles solve and what they miss

Native MariaDB grants do a great job of limiting which tables an account can touch. They block an n8n workflow from dropping schemas or reading tables outside its assigned scope. If an AI agent invents a bad table name, the database rejects that query right away. Separating accounts by workflow also helps database admins see which group of jobs uses resources.

Still, database grants only check who logs in and which table the query names. Once the session starts, MariaDB trusts every valid statement that uses those allowed tables. A read grant on a customer table returns every column in the matched rows by default. That query result often includes raw emails, phone numbers, card numbers, or national IDs. In an AI workflow, those sensitive fields go straight to the chat model prompt. Native permissions also cannot pause a risky update to ask a human for approval first. Finally, shared n8n logins hide which person or workflow run sent a specific SQL query.

AI Agent Permissions + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Separating read and write accounts for AI agents

AI agents create SQL statements on the fly from plain text user questions. Because the agent picks the tool and writes the query, static grants need extra care. Teams should never attach a write account to an agent that only answers user questions. Even with a read-only user, a broad select query can pull millions of rows at once. Good setups pair narrow table views with query timeouts and row limits on the database user. That way, one bad prompt cannot lock up MariaDB memory or expose full customer tables.

Inspect every MySQL query and response in flight

Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev is an open-source proxy that runs as a sidecar for your MySQL. It reads plain queries, prepared statements, and cursors on the wire.

First, hoop.dev guardrails block banned actions before MySQL runs them. An AI Analyzer you configure can score intent, and hoop.dev data masking rewrites sensitive string columns in results. Every query and verdict goes to the resource audit trail. Find the open-source binary on GitHub.

Frequently asked questions

Should n8n workflows share one MariaDB user account?

No, sharing one account gives every workflow the highest permission needed by any single job. Create separate MariaDB users for read tasks, write tasks, and AI agent tools instead.

How do n8n AI agents run queries against MariaDB?

You attach a compatible SQL tool sub-node or a workflow tool to the AI Agent node. The agent decides when to call that tool and passes the query through your saved login.

Can native MariaDB permissions hide sensitive columns in query results?

MariaDB supports column grants and views, which fail a query if a forbidden column is named. Still, native grants cannot rewrite emails, phone numbers, or card numbers inside returned rows on the fly.

The query runs. The emails stay hidden.