# Is there any way to do dynamic configuration for mysql node in node-red?

**URL:** https://discourse.nodered.org/t/is-there-any-way-to-do-dynamic-configuration-for-mysql-node-in-node-red/22354
**Category:** General
**Created:** [28 February 2020 06:28 UTC](https://discourse.nodered.org/t/is-there-any-way-to-do-dynamic-configuration-for-mysql-node-in-node-red/22354 "2020-02-28T06:28:53Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Jignesh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jignesh/32/28024_2.png) [@Jignesh](https://discourse.nodered.org/u/Jignesh)
#### Post date: [28 February 2020 06:28 UTC](https://discourse.nodered.org/t/is-there-any-way-to-do-dynamic-configuration-for-mysql-node-in-node-red/22354/1 "2020-02-28T06:28:53Z")

</div>

I am using node-red-node-mysql node to connect with mySQL database. I want to set my database credential (i.e. server name, db name, uid and password) from global variables.

Is there any way to do it?

---

<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: [28 February 2020 10:01 UTC](https://discourse.nodered.org/t/is-there-any-way-to-do-dynamic-configuration-for-mysql-node-in-node-red/22354/2 "2020-02-28T10:01:25Z")

</div>

not at this point in time.

---

<div class="post-metadata">

### Author: ![unixneo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/unixneo/32/17441_2.png) [@unixneo](https://discourse.nodered.org/u/unixneo)
#### Post date: [28 February 2020 10:20 UTC](https://discourse.nodered.org/t/is-there-any-way-to-do-dynamic-configuration-for-mysql-node-in-node-red/22354/3 "2020-02-28T10:20:40Z")

</div>

You can do the "next best thing" and just put the params in a function node, save it as a custom flow (of whatever the correct word is for it, my bad if I got the exact word wrong again), and use it to pass the params to another MySQL function (where you have your custom MySQL logic).

FYI, I do not use the mysql plugin ( `node-red-node-mysql` ) and write all my MySQL code in a function node (it is really simple anyway, some basics below) because it works much better, at least for me. This is especially true (again, for me, YMMV) because my MySQL configuration uses a socket for the MySQL port, and the mysql plugin only accepts an int as a port number (not a string where we can pass a unix socket as the port).

Example:

```auto
var mysql = global.get("mysql");
var connection = mysql.createConnection({
    host: 'localhost',
    user: 'my_cool_dbuser',
    port: '/var/run/mysqld/mysqld.sock',
    password: 'my_cool_password',
    database: 'my_big_amazing_database'
});

```

etc etc

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [28 April 2020 10:20 UTC](https://discourse.nodered.org/t/is-there-any-way-to-do-dynamic-configuration-for-mysql-node-in-node-red/22354/4 "2020-04-28T10:20:42Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
