节点与集成

MySQL

Use the MySQL node to automate work in MySQL, and integrate MySQL with other applications. n8n has built-in support for a wide range of MySQL features, including executing an SQL query, as well as inserting, and updating rows in a database.

On this page, you'll find a list of operations the MySQL node supports and links to more resources.

Operations

  • Delete
  • Execute SQL
  • Insert
  • Insert or Update
  • Select
  • Update

Templates and examples

Browse n8n-nodes-base.mysql integration templates or search all templates

Related resources

Refer to MySQL's Connectors and APIs documentation for more information about the service.

Refer to MySQL's SELECT statement documentation for more information on writing SQL queries.

Use query parameters

When creating a query to run on a MySQL database, you can use the Query Parameters field in the Options section to load data into the query. n8n sanitizes data in query parameters, which prevents SQL injection.

For example, you want to find a person by their email address. Given the following input data:

js
[
    {
        "email": "alex@example.com",
        "name": "Alex",
        "age": 21
    },
    {
        "email": "jamie@example.com",
        "name": "Jamie",
        "age": 33
    }
]

You can write a query like:

sql
SELECT * FROM $1:name WHERE email = $2;

Then in Query Parameters, provide the field values to use. You can provide fixed values or expressions. For this example, use expressions so the node can pull the email address from each input item in turn:

js
// users is an example table name
users, {{ $json.email }}

Common issues

For common errors or issues and suggested resolution steps, refer to Common issues.

官方原文和授权

本页来自 N8N 英文官方网站固定快照,并转换成 xueai 静态页面。内容以 N8N 持续更新的官方页面为准。

来源、授权与修改

本站保留许可证、固定提交号、社区作者和修改说明,不代表 n8n 对本站背书。

查看许可证查看来源和修改说明