I need some help with setting environment variables in the MySQL database node within a Docker-based Node-RED setup.
What I’m Trying to Achieve
I want to define my database connection details (host, user, password, database name, etc.) as environment variables in docker-compose.yml and reference them inside the MySQL configuration node.
Not sure if this is possible or the best approach, but if anyone has done this before without modifying the MySQL node source code, I’d love to hear your ideas!
Assuming you configured your env variables for the docker, all you need to do is refer to them with ${...}.
for example, if you have an env var named DB_PORT in the docker, just set ${DB_PORT} in your node configuration and it will resolve automatically.
Thanks for the correction @Steve-Mcl
This has me wondering however - I don't see in the source, that there is any magic for this to happen in the Node itself.
So is this evaluated - before the Node its self is started?
In truth, all nodes should be updated to use the TypedInput. The TypedInput permits the $ dropdown which expands usability to allow things like $192.168.1.${MY_NODE}:${MY_PORT} where as the textbox version ONLY permits a single ${...} var without interpolation
Yeah also this single env configuration would be easier to set and also flexible rather than setting different one's. I've seen this recently while playing around with redis .
Hi, I finally tested it out. I replaced my old configuration with environment variables, keeping everything else the same. However, I'm now encountering a "Too many connections" error.