How to Configure n8n MariaDB Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up n8n mariadb read only access by creating a restricted database user. Then you put those credentials into a MySQL tool sub-node or database node. Teams often start by reusing a shared admin account for quick workflow tests. That broad role lets an automated workflow or AI agent change or delete data. Giving the node a select-only database account blocks write steps at the database level. How to set up n8n mariadb read only access MariaDB uses the MySQL wire protocol, so you use the

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 read only access by creating a restricted database user. Then you put those credentials into a MySQL tool sub-node or database node. Teams often start by reusing a shared admin account for quick workflow tests. That broad role lets an automated workflow or AI agent change or delete data. Giving the node a select-only database account blocks write steps at the database level.

How to set up n8n mariadb read only access

MariaDB uses the MySQL wire protocol, so you use the MySQL node in n8n. For AI tasks, the n8n AI Agent node pairs a chat model with tools. The agent decides which tools to call to complete a task. You must attach at least one tool sub-node to an AI Agent node. From n8n 1.82.0, the 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 Agent tasks, you attach a MySQL tool sub-node to a recent Agent node.

Before you add credentials in n8n, create a dedicated user inside MariaDB. Grant that user only the privilege to read tables in your target schema. Do not grant permission to insert, update, delete, or drop tables. Next, open your n8n workflow and add the MySQL tool sub-node. Enter the host, database name, and the new read-only user credentials. When the agent runs, it converts questions into SQL queries and runs them. MariaDB checks the user role and rejects any query that tries to change data.

Why database roles alone leave gaps in AI workflows

A read-only database user stops an n8n workflow from deleting or changing rows. Still, database roles only check who logs in and which tables they can read. A read-only user can still read every column in an allowed table by default. When an AI agent runs a query, the results go to the chat model. Those results often contain emails, phone numbers, card numbers, or national IDs.

Native MariaDB privileges do not rewrite sensitive fields inside query results on the fly. If a table holds customer records, a read query pulls all of those fields. Also, static credentials stored in n8n stay active until an engineer rotates them. Teams also lack a single audit log that links n8n runs to exact queries. You need controls that inspect queries in flight and mask sensitive fields in results.

Auditor Read-Only Access + Customer Support Access to Production: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Managing credentials and query rules across workflows

As teams build more workflows, managing static database users for each node gets hard. One workflow might need sales tables while another needs support tickets. Creating and rotating separate MariaDB users for every single workflow takes too much time. Most teams end up sharing one read-only account across many different n8n workflows.

When many workflows share one database user, database logs show only that shared name. You cannot tell which workflow or user triggered a slow or broad select query. A better setup checks identity per request and applies data masking rules in flight. Masking rewrites matched fields like emails or card numbers in results before n8n processes 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

Which n8n node should I use to query MariaDB with an AI agent?

Use the MySQL tool sub-node attached to a recent AI Agent node. The older SQL Agent mode is deprecated from n8n 1.82.0 and removed in 3.0.

Does a read-only MariaDB user stop AI agents from reading sensitive columns?

No, a read-only role allows reading all columns in the permitted tables by default. To hide emails or card numbers in results, you need dynamic data masking.

Can the n8n AI Agent decide when to run a MariaDB query on its own?

Yes, the AI Agent node works as a Tools Agent by default. The agent picks which attached tool sub-node to call to finish a task.

The query runs. The emails stay hidden.