Registry / database / node-red-contrib-mysql-config

node-red-contrib-mysql-config

JSON →
library1.0.4jsnpmunverified

A Node-RED node for querying MySQL and MariaDB databases, forked from node-red-contrib-stackhero-mysql (v1.0.4). This version enables configuring database connections via environment variables instead of hardcoding credentials in the Node-RED UI. It supports parameterized queries (using named placeholders in msg.topic and values in msg.payload) to prevent SQL injections. Released as a minor fork, it maintains the same API as the original but adds CI/CD-friendly configuration. Suitable for Node-RED instances deployed across environments where credentials must be set at runtime.

npm install node-red-contrib-mysql-config
INSTALL
IMPORT
SIG · NODE-RED-CONTRIB-M
N
node-red-contrib-mysql-config
databasejavascriptv1.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
Install via npm: npm install node-red-contrib-mysql-config
Node-RED nodes are loaded by Node-RED's runtime; no direct import in user code. The node appears in the palette as 'mysql-config'.

Shows how to perform a parameterized SQL query using the mysql-config node, with named placeholders in topic and values in payload.

// Flow example in Node-RED // Inject node: set msg.topic and msg.payload msg.topic = 'SELECT * FROM `users` WHERE `name` = :name AND `age` > :age;'; msg.payload = { name: 'Adrien', age: 30 }; return msg; // Connect to mysql-config node. Output is in msg.payload.
Debug
Known issues
gotchaDo not embed user input directly in msg.topic via string concatenation; always use parameterized queries via msg.payload.
fix
Use named placeholders (:name) in topic and pass values as object keys in payload.
affects: >=1.0
gotchaEnvironment variable names must be set in the node configuration UI (not in flow code) and the node will resolve them at deployment time.
affects: >=1.0
Errors
Common errors & fixes
Error: Cannot find module 'mysql2'
Missing mysql2 dependency in the Node-RED environment.
fix
Run 'npm install mysql2' in the Node-RED user directory (usually ~/.node-red).
Error: getaddrinfo ENOTFOUND <host>
Database host environment variable not set or incorrect.
fix
Check that the environment variable for host is set and the node configuration matches the variable name.
SyntaxError: You have an error in your SQL syntax
Invalid SQL in msg.topic.
fix
Ensure SQL syntax is correct for MySQL/MariaDB and verify string escaping.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies
mysql2requiredMySQL/MariaDB client driver for Node.js
Agent activity
5 hits · last 30 days
node
4
Resources
node-red-contrib-mysql-config — npm install node-red-contrib-mysql-config · libregistry