node-red-node-mysql 0.1.0

A Node-RED node to read and write to a MySQL database

npm install node-red-node-mysql

A Node-RED node to read and write to a MySQL database.


Either use the Node-RED Menu - Manage Palette - Install, or run the following command in your Node-RED user directory - typically ~/.node-red

npm i node-red-node-mysql


Allows basic access to a MySQL database.

This node uses the query operation against the configured database. This does allow both INSERTS and DELETES.

By its very nature it allows SQL injection... so be careful out there...

The msg.topic must hold the query for the database, and the result is returned in msg.payload.

Typically the returned payload will be an array of the result rows.

If nothing is found for the key then null is returned.

The reconnect retry timeout in milliseconds can be changed by adding a line to settings.js

mysqlReconnectTime: 30000,

Preparing Queries

msg.payload=[24, 'example-user'];
msg.topic="INSERT INTO users (`userid`, `username`) VALUES (?, ?);"
return msg;

with named parameters:

msg.topic="INSERT INTO users (`userid`, `username`) VALUES (:userToChange, :newUsername) ON DUPLICATE KEY UPDATE `username`=:newUsername;"
return msg;


Documentation of the used Node.js package

Node Info

Version: 0.1.0
Updated 4 months, 1 week ago
License: Apache-2.0
Rating: 3.0 2


254 in the last day
2218 in the last week
10136 in the last month


  • MySQLdatabase
  • mysql


  • node-red
  • mysql