Mysql node config externally

Hi,
I am using mysql node and successfully connect to my DB. Mysql node is currently configured from the node settings; such as "Host", "User", "Password" entries.
I would like to send these config parameters externally, using a function node for instance rather than hardcoding in the node settings.
The reason for this is, within the same project I will need to access different databases depending on the credentials I receive from a login page. Therefore, I need to make mysql config dynamic.

Any advice is appreciated.
Thanks

Are the databases duplicates of each other (ie same tables and columns)? Or are they different tables in the different tables?

At any rate the user and passwords are not setable outside the node.

Databases have the same structure, except for the data will be different.
I can duplicate the mysql node as much as client number, but that wouldn't be very practical.

Do you have any suggestions?
Thanks

Not really, maybe someone else will pipe in.

Hi,

I also have exactly the same need.

Any thoughts?

Cheers,

Paul

Here is one thought. Depending on the number of databases, you could have one mysql node for each database and then add a userid to the msg (msg.dbuser) and then check that with a switch node to determine which mysql node to use.

Hi,

I have the solution... I asked a developer on my team to write an updated MYSQL node that externalizes the credentials and configuration handling. He completed it and it works.

He will make some documentation etc. updates and then open-source it so that other Node-RED users can use it.

Cheers,

Paul

1 Like

So does this mean if someing gets a copy of the flow they will be able to look at it and find the MySQL user name and password??? Sounds like a security issue to me.

presumably it means the database, userid and password can be "injected" somehow... not clear when it takes effect ? does it mean it makes a new connection for every query ? or what happens if the underlying connection gets changed mid way through a set of updates ? - but no doubt all will become clear.