# Node-red-contrib-mysql2 node

**URL:** https://discourse.nodered.org/t/node-red-contrib-mysql2-node/64096
**Category:** General
**Created:** [18 June 2022 06:52 UTC](https://discourse.nodered.org/t/node-red-contrib-mysql2-node/64096 "2022-06-18T06:52:40Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![bertaud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bertaud/32/80981_2.png) [@bertaud](https://discourse.nodered.org/u/bertaud)
#### Post date: [18 June 2022 06:52 UTC](https://discourse.nodered.org/t/node-red-contrib-mysql2-node/64096/1 "2022-06-18T06:52:40Z")

</div>

i saw in nodered documentation there is an existing node node-red-contrib-mysql2 node where it is possible to get parameters from incomming msg  
"We can also send the server details using `msg.server`, without adding those details at node level"

As the documentation is light on this topic i m unable to do it working. Can you clarify the syntax we should use?  
i use the following one but not working

var test= {Host:mariadb\_Host,Port:mariadb\_Port, Username: mariadb\_Username, Password: mariadb\_Password, Database: 'myDatabase'}  
newmsg.Server=test

---

<div class="post-metadata">

### Author: ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)
#### Post date: [18 June 2022 12:17 UTC](https://discourse.nodered.org/t/node-red-contrib-mysql2-node/64096/2 "2022-06-18T12:17:05Z")

</div>

yea the documentation is a bit limited on the node but if you go to **Import (Ctrl+I) \> Examples**  
you should see an example flow for node-red-contrib-mysql2

From their example `msg.server` should be :

```auto
{
"host":"chq05-w10-tst01.axcess-financial.com",
"port":3306,
"username":"username",
"password":"password",
"db":"robot"
}

```

js is case-sensitive so keep the properties as lowercase

---

<div class="post-metadata">

### Author: ![bertaud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bertaud/32/80981_2.png) [@bertaud](https://discourse.nodered.org/u/bertaud)
#### Post date: [18 June 2022 13:57 UTC](https://discourse.nodered.org/t/node-red-contrib-mysql2-node/64096/3 "2022-06-18T13:57:14Z")

</div>

it doesn't works. Seems the node doesn't use the IP provide as i get "connect ECONNREFUSED 127.0.0.1:3306"

below the code in function node

```auto
var newmsg={};
newmsg.Server={"host":"11.1.1.228","port":"3306", "username": "user", "password": "@L8S", "database": "test"}
//newmsg.Password=mariadb_Password;
newmsg.topic="select id,profileName from ProfileEntity;";
//node.log("------ GET ProfileEntity mysql(req)="+newmsg.topic);
node.warn(newmsg)
return newmsg;

```

---

<div class="post-metadata">

### Author: ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)
#### Post date: [18 June 2022 14:04 UTC](https://discourse.nodered.org/t/node-red-contrib-mysql2-node/64096/4 "2022-06-18T14:04:10Z")

</div>

i havent used the node but from the example  
the database property should be `db` and not `database`  
also you have used msg.Server with capital S. i believe it should be lowercase

```auto
var newmsg={};

newmsg.server={
"host":"11.1.1.228",
"port":"3306", 
"username": "user", 
"password": "@L8S", 
"db": "test"
}

//newmsg.Password=mariadb_Password;
newmsg.topic="select id,profileName from ProfileEntity;";
//node.log("------ GET ProfileEntity mysql(req)="+newmsg.topic);
node.warn(newmsg)
return newmsg;

```

---

<div class="post-metadata">

### Author: ![bertaud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bertaud/32/80981_2.png) [@bertaud](https://discourse.nodered.org/u/bertaud)
#### Post date: [18 June 2022 14:30 UTC](https://discourse.nodered.org/t/node-red-contrib-mysql2-node/64096/5 "2022-06-18T14:30:52Z")

</div>

good eyes !  
you are right but still face the same problem  
"connect ECONNREFUSED 127.0.0.1:3306"

```auto
var newmsg={};
newmsg.Server={"host":"11.1.1.228","port":"3306", "username": "user", "password": "@L8S", "db": "test"}
//newmsg.Password=mariadb_Password;
newmsg.topic="select id,profileName from ProfileEntity;";
//node.log("------ GET ProfileEntity mysql(req)="+newmsg.topic);
node.warn(newmsg)
return newmsg;

```

---

<div class="post-metadata">

### Author: ![bertaud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bertaud/32/80981_2.png) [@bertaud](https://discourse.nodered.org/u/bertaud)
#### Post date: [18 June 2022 14:37 UTC](https://discourse.nodered.org/t/node-red-contrib-mysql2-node/64096/6 "2022-06-18T14:37:05Z")

</div>

sorry i forget to change newmsg.Server to newmsg.server

With this change it works as expected. Thanks a lot to your good eyes

---

<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: [2 July 2022 14:37 UTC](https://discourse.nodered.org/t/node-red-contrib-mysql2-node/64096/7 "2022-07-02T14:37:46Z")

</div>

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