How to Configure n8n MySQL Credentials

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up n8n mysql credentials by saving your database host, user, and password. Then you attach those saved details to a MySQL node or tool sub-node. Most teams start by reusing an existing app login to move fast. That shortcut becomes risky when workflows or AI agents hold broad database rights. A single bad query can change rows or return private records. How n8n mysql credentials work in workflows and agents In n8n, you store database login details once inside the credential store. Any

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 credentials by saving your database host, user, and password. Then you attach those saved details to a MySQL node or tool sub-node. Most teams start by reusing an existing app login to move fast. That shortcut becomes risky when workflows or AI agents hold broad database rights. A single bad query can change rows or return private records.

How n8n mysql credentials work in workflows and agents

In n8n, you store database login details once inside the credential store. Any workflow node that talks to MySQL can pick that saved entry. When the workflow runs, the node opens a direct session to your database. It logs in as the MySQL user you saved in that entry.

This pattern also applies when you build AI workflows in n8n. The n8n AI Agent node pairs a chat model with one or more 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 old agent type setting is deprecated. All AI Agent nodes now work as a Tools Agent. Node version 1 is removed in n8n 3.0. For SQL tasks, the docs say to use a MySQL tool sub-node instead.

Previously, the deprecated SQL Agent handled natural language questions directly. It could convert questions into SQL queries, run them, and show the results. That older setup also let you pick included tables for the agent. Today, you attach a MySQL tool sub-node to a recent AI Agent node. That sub-node uses your stored n8n mysql credentials to run queries.

How database roles shape what n8n can do

MySQL checks permissions at the user and host level when n8n logs in. The database only sees the username and password stored in n8n. It does not know which specific n8n workflow or user triggered the run. Every node sharing that login gets the exact same table rights.

To reduce risk, teams often create a dedicated MySQL user for n8n. You can grant read-only rights on specific tables to that user. You can also block drop, delete, or alter statements at the database level. This stops a broken workflow or confused AI agent from wiping out data.

Ephemeral Credentials + MySQL Access Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Still, static database roles take time to manage across many workflows. One workflow might need to write orders, while another only reads reports. If you share one login across both, the read workflow gains write power. Creating a separate MySQL user for every single workflow adds heavy admin work.

What native credentials solve and what stays exposed

Native credentials solve the problem of storing passwords inside workflow steps. Your team can build automations without typing database secrets into every node. Combined with least-privilege MySQL roles, you can control which tables n8n can touch.

Still, a database login only decides who can open a session. It does not inspect what individual SQL statements do in flight. Once logged in, an AI agent can read every column in an allowed table. If that table holds emails, phone numbers, card numbers, or national IDs, raw values return. The chat model then processes those sensitive fields in plain text. Native MySQL roles also cannot pause a risky update for human approval. You need statement-level controls to mask sensitive fields and review dangerous queries.

Add wire guardrails and masking beside MySQL

Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev runs beside the database as a sidecar for your MySQL. It keeps your login setup and drivers as they are while checking queries on the wire.

With hoop.dev MySQL support, guardrails refuse bad queries before they run and return a readable MySQL error. Data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.

Frequently asked questions

How should I connect MySQL to an n8n AI Agent node?

Attach a MySQL tool sub-node to a recent AI Agent node. From n8n 1.82.0, all AI Agent nodes run as a Tools Agent. Select your saved MySQL login inside that tool sub-node.

Should n8n workflows share one MySQL user account?

No, sharing one broad account gives every workflow the same database power. Create separate MySQL users for read-only tasks and write tasks. Grant each user access only to the tables it needs.

Can MySQL permissions hide sensitive columns from AI agents?

MySQL offers column-level grants, but they are hard to maintain as schemas change. If an agent can read a column, it gets the raw text. Data masking rewrites matched fields like emails or card numbers in results.

The query runs. The emails stay hidden.