MySQL Query Node
Run a parameterised SELECT, INSERT, or UPDATE against an external MySQL or MariaDB database from within an automation step.
The MySQL Query node opens a connection to an external MySQL/MariaDB database, executes a parameterised query, and stores the result set as a flow variable.
> Security: Always use parameterised queries (? placeholders) — never interpolate user input directly into the SQL string. The node uses mysql2 under the hood, which protects against SQL injection when placeholders are used correctly.
---
| Field | Type | Required | Description |
|---|---|---|---|
host | string | Yes | Database host (IP or hostname) |
port | integer | No | Default: 3306 |
database | string | Yes | Database name |
user | string | Yes | DB username |
password | string | Yes | DB password — reference a saved credential: {{credentials.myDbCred}} |
ssl | boolean | No | Enable TLS (recommended for remote databases) |
query | string | Yes | Parameterised SQL. Use ? for parameters |
params | string | No | JSON array of values for the ? placeholders |
outputVar | string | No | Variable name to store results (default: queryResult) |
---
| Variable | Description |
|---|---|
{{variables.queryResult}} | Array of row objects for SELECT; affectedRows integer for INSERT/UPDATE/DELETE |
---
json
{
"host": "db.mycompany.com",
"database": "crm",
"user": "readonly",
"password": "{{credentials.crmDbPassword}}",
"query": "SELECT id, name, plan FROM customers WHERE email = ? LIMIT 1",
"params": "["{{lead.email}}"]",
"outputVar": "customer"
}
Access result: {{variables.customer[0].plan}}
---
json
{
"query": "INSERT INTO touchpoints (lead_email, action, created_at) VALUES (?, ?, NOW())",
"params": "["{{lead.email}}", "email_sent"]"
}
---
- Store DB passwords in Settings → Credentials — never paste them raw into the node config
- Use
ssl: truefor any database not on the same private network - SELECT queries return an array — if you expect one row, use
{{variables.customer[0].name}}to access it - The connection is closed after each execution — there's no persistent connection pool per automation