N8n MySQL Node

Published
Length
3 min read

Luis Felipe Dias

All posts

The n8n mysql node connects your workflows and AI agents to a MySQL database. It lets your team read, write, and update rows during automated runs. Teams use this integration to sync app records, build reports, and run agent tasks. In recent versions, an AI Agent node can also call a MySQL tool sub-node. The agent decides when to query the database to finish a user request. How the n8n mysql node works in practice In a standard workflow, the n8n mysql node runs at a set step. You pick an act

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.

The n8n mysql node connects your workflows and AI agents to a MySQL database. It lets your team read, write, and update rows during automated runs.

Teams use this integration to sync app records, build reports, and run agent tasks. In recent versions, an AI Agent node can also call a MySQL tool sub-node. The agent decides when to query the database to finish a user request.

How the n8n mysql node works in practice

In a standard workflow, the n8n mysql node runs at a set step. You pick an action like inserting rows, updating records, or running a query. Data from earlier steps flows into the node as input items. The node talks to your MySQL server and sends the output to the next step.

For AI tasks, n8n uses an AI Agent node paired with a chat model. You attach at least one tool sub-node to the AI Agent node. From version 1.82.0, every AI Agent node works as a Tools Agent. The older agent type setting is deprecated, and version 3.0 removes node version 1.

For SQL Agent tasks, n8n docs recommend a MySQL tool sub-node with a recent Agent. The deprecated SQL Agent took plain text questions and turned them into SQL queries. It ran those queries on MySQL, Postgres, or SQLite and showed the results. Today, attaching a MySQL tool sub-node or a Call n8n Workflow Tool handles this job. You can also attach an HTTP Request Tool, a Custom Code Tool, or MCP servers.

Security and operational tradeoffs for MySQL workflows

Running database steps from an automation app creates clear security tradeoffs for your team. To connect, you store a MySQL user key and password inside the workflow app. Every workflow or AI agent using that key gets the exact same database role.

Database roles only check permissions at the table or column level when a session starts. Once the session is open, any valid query for that role will run. If an AI agent builds a bad query, a broad role will not stop it. The agent could delete rows or pull a massive table by mistake.

MySQL Access Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Standard database roles also do not filter sensitive fields inside query results. When a workflow reads a user table, the database returns raw text to the app. Emails, phone numbers, card numbers, and national IDs flow right into the workflow log. In AI workflows, those fields also go to the external chat model.

Shared workflow keys also make database logs hard to audit. Your MySQL log shows the shared app user instead of the person who ran it. Teams need query checks, human approvals, and field masking to keep live data safe. Masking rewrites matched fields like emails and card numbers in results before the agent acts.

How to harden database runs for agents and teams

Start by creating a dedicated MySQL user with read-only rules for agent tools. Only grant access to the specific tables that the workflow needs to read. Keep write and delete actions inside fixed workflows rather than open agent prompts.

Next, place a database proxy between your workflow app and the MySQL server. A proxy checks every query before it reaches the database engine. It can block dangerous statements, require human approval, and log the exact run context. It can also mask emails, phone numbers, card numbers, and national IDs in results.

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 sits inline in the wire protocol beside the database as a sidecar for your MySQL. On every production query an agent or engineer sends, hoop.dev decides to pass, mask, block, or escalate it for human review.

With hoop.dev MySQL support, guardrails refuse bad queries before they run or hold risky calls for approval, while 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 do I build a SQL agent in recent n8n versions?

Use an AI Agent node and attach a MySQL tool sub-node to it. Since version 1.82.0, all AI Agent nodes run as a Tools Agent by default. The agent reads the user prompt and decides when to call the MySQL tool.

What happened to the old SQL Agent option in n8n?

N8n deprecated the agent type setting in version 1.82.0 and removes node version 1 in 3.0. Instead of the old SQL Agent, attach a MySQL or Postgres tool sub-node. You can also link a Call n8n Workflow Tool to run fixed SQL steps.

How can teams protect sensitive data when an AI agent queries MySQL?

Database roles alone return raw rows once a query passes table permission checks. Routing traffic through a proxy lets you apply data masking on the way back. Masking rewrites matched fields like card numbers, phone numbers, and emails in query results.

The query runs. The emails stay hidden.