MySQLExtend icon

MySQLExtend

Upsert, get, add and update data in MySQL

Overview

The MySQLExtend node for n8n allows you to execute custom SQL queries against a MySQL database. In the context of the "Default" Resource and "Execute Query" Operation, this node is designed to run arbitrary SQL statements provided by the user and return the results as JSON. This is particularly useful for advanced users who need to perform complex data retrieval, aggregation, or manipulation that goes beyond standard CRUD operations.

Common scenarios:

  • Fetching specific records with custom filters (e.g., SELECT id, name FROM product WHERE id < 40)
  • Running aggregate functions (e.g., SELECT COUNT(*) FROM orders WHERE status = 'pending')
  • Executing multi-table joins or subqueries
  • Performing administrative queries (with caution)

Practical example:
Suppose you want to retrieve all products with an ID less than 40. You would set the Query property to:

SELECT id, name FROM product WHERE id < 40

The node will execute this query and return the resulting rows as JSON objects.

Properties

Name Type Meaning
Query String The SQL query to execute. This should be a valid SQL statement supported by MySQL.

Output

  • The output is a JSON array where each element represents a row returned by the executed SQL query.
  • Each object in the array contains key-value pairs corresponding to the columns selected in your query.

Example output:

[
  { "id": 1, "name": "Product A" },
  { "id": 2, "name": "Product B" }
]
  • If an error occurs and "Continue On Fail" is enabled, the output will include an object like:
[
  { "error": "Error message here" }
]

Dependencies

  • External Service: Requires access to a MySQL-compatible database.
  • Credentials: You must configure MySQL credentials in n8n under the name mySqlExtend. These may include host, port, user, password, database, and optional SSL parameters (CA certificate, client certificate, client private key).
  • n8n Configuration: No special environment variables are required beyond standard credential setup.

Troubleshooting

Common issues:

  • Invalid SQL Syntax: If the query is malformed, the node will throw a MySQL syntax error. Double-check your SQL statement for typos or missing keywords.
  • Connection Errors: If credentials are incorrect or the database is unreachable, you'll receive connection-related errors. Ensure network access and correct credential configuration.
  • Permission Denied: The database user may lack permission to execute certain queries. Verify user privileges in your MySQL server.
  • Large Result Sets: Very large queries may cause performance issues or timeouts. Consider limiting results with LIMIT clauses.

Error messages:

  • "ER_PARSE_ERROR": Indicates a syntax error in your SQL query.
  • "ER_ACCESS_DENIED_ERROR": Credentials are incorrect or user lacks permissions.
  • "connect ECONNREFUSED": Unable to reach the MySQL server at the specified host/port.
  • "The operation \"...\" is not supported!": The selected operation is not implemented; check your node configuration.

How to resolve:

  • Review and correct your SQL query.
  • Check and update your MySQL credentials in n8n.
  • Ensure the MySQL server is running and accessible from the n8n instance.
  • Grant necessary permissions to the database user.

Links and References

Discussion