# Mysql node config externally

**URL:** <https://discourse.nodered.org/t/mysql-node-config-externally/8626>\
**Category:** General\
**Created:** [5 March 2019 10:52 UTC](https://discourse.nodered.org/t/mysql-node-config-externally/8626 "2019-03-05T10:52:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![keremkos](https://avatars.discourse-cdn.com/v4/letter/k/f07891/32.png) [@keremkos](https://discourse.nodered.org/u/keremkos)\
**Post date:** [5 March 2019 10:52 UTC](https://discourse.nodered.org/t/mysql-node-config-externally/8626/1 "2019-03-05T10:52:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [5 March 2019 14:21 UTC](https://discourse.nodered.org/t/mysql-node-config-externally/8626/2 "2019-03-05T14:21:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![keremkos](https://avatars.discourse-cdn.com/v4/letter/k/f07891/32.png) [@keremkos](https://discourse.nodered.org/u/keremkos)\
**Post date:** [5 March 2019 22:24 UTC](https://discourse.nodered.org/t/mysql-node-config-externally/8626/3 "2019-03-05T22:24:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [6 March 2019 00:42 UTC](https://discourse.nodered.org/t/mysql-node-config-externally/8626/4 "2019-03-06T00:42:16Z")

</div>

Not really, maybe someone else will pipe in.

---

<div class="post-metadata">

**Author:** ![paulkeates](https://avatars.discourse-cdn.com/v4/letter/p/9de053/32.png) [@paulkeates](https://discourse.nodered.org/u/paulkeates)\
**Post date:** [6 September 2021 23:54 UTC](https://discourse.nodered.org/t/mysql-node-config-externally/8626/5 "2021-09-06T23:54:12Z")

</div>

Hi,

I also have exactly the same need.

Any thoughts?

Cheers,

Paul

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [7 September 2021 10:06 UTC](https://discourse.nodered.org/t/mysql-node-config-externally/8626/6 "2021-09-07T10:06:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![paulkeates](https://avatars.discourse-cdn.com/v4/letter/p/9de053/32.png) [@paulkeates](https://discourse.nodered.org/u/paulkeates)\
**Post date:** [8 September 2021 16:24 UTC](https://discourse.nodered.org/t/mysql-node-config-externally/8626/7 "2021-09-08T16:24:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [9 September 2021 09:13 UTC](https://discourse.nodered.org/t/mysql-node-config-externally/8626/8 "2021-09-09T09:13:47Z")

</div>

> [@paulkeates](#):
>
> 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.

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.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [9 September 2021 10:43 UTC](https://discourse.nodered.org/t/mysql-node-config-externally/8626/9 "2021-09-09T10:43:20Z")

</div>

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.
