# Connection to database via node mysql-r2 does not work. But connection with node mysql does

**URL:** <https://discourse.nodered.org/t/connection-to-database-via-node-mysql-r2-does-not-work-but-connection-with-node-mysql-does/90130>\
**Category:** Developing Nodes\
**Tags:** database\
**Created:** [12 August 2024 16:39 UTC](https://discourse.nodered.org/t/connection-to-database-via-node-mysql-r2-does-not-work-but-connection-with-node-mysql-does/90130 "2024-08-12T16:39:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chuckf201](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chuckf201/32/91382_2.png) [@chuckf201](https://discourse.nodered.org/u/chuckf201)\
**Post date:** [12 August 2024 16:39 UTC](https://discourse.nodered.org/t/connection-to-database-via-node-mysql-r2-does-not-work-but-connection-with-node-mysql-does/90130/1 "2024-08-12T16:39:21Z")

</div>

> Blockquote  
> [  
> {  
> "id": "595824d334f50ad0",  
> "type": "tab",  
> "label": "db test",  
> "disabled": false,  
> "info": "",  
> "env":   
> },  
> {  
> "id": "193246244b0ceb0a",  
> "type": "function",  
> "z": "595824d334f50ad0",  
> "name": "testing query",  
> "func": "var myMsg = msg.payload\n\n// t=msg.topic="SELECT DateAndTime, Temperature, Humidity, BarrPress FROM 'temp-at-interrupt' where minute(Time)= '00' order by DateAndTime DESC LIMIT '"+msg.payload+"'";\n\n\n// t = "SELECT \* FROM NodeRed.7bchannels WHERE channel="+msg.payload \n// return {topic:t} Probably need to format payload as a string: t = "SELECT \* FROM NodeRed.7bchannels WHERE channel='"+msg.payload+"'" \n\n//var t = "SELECT DateAndTime, Temperature, Humidity, BarrPress FROM `weather_1` where minute(Time)= '00' order by DateAndTime DESC LIMIT " + myMsg\n//var t = "select \* FROM `weather_1` DESC LIMIT 5" // + myMsg\n\n//return {topic:t}\n//\nmsg.topic="select \* from weather\_1 limit 5"\nreturn msg\n",  
> "outputs": 1,  
> "timeout": 0,  
> "noerr": 0,  
> "initialize": "",  
> "finalize": "",  
> "libs": ,  
> "x": 330,  
> "y": 180,  
> "wires": [  
> [  
> "c8df24e1eb336d1a",  
> "e7c6b6e59db57194",  
> "9f53dada8eb45390"  
> ]  
> ]  
> },  
> {  
> "id": "0809a9ec086585de",  
> "type": "inject",  
> "z": "595824d334f50ad0",  
> "name": "",  
> "props": [  
> {  
> "p": "payload"  
> },  
> {  
> "p": "topic",  
> "vt": "str"  
> }  
> ],  
> "repeat": "",  
> "crontab": "",  
> "once": false,  
> "onceDelay": 0.1,  
> "topic": "12",  
> "payload": "12",  
> "payloadType": "str",  
> "x": 120,  
> "y": 180,  
> "wires": [  
> [  
> "193246244b0ceb0a",  
> "47e7279e882583b2"  
> ]  
> ]  
> },  
> {  
> "id": "c8df24e1eb336d1a",  
> "type": "debug",  
> "z": "595824d334f50ad0",  
> "name": "debug 3",  
> "active": false,  
> "tosidebar": true,  
> "console": false,  
> "tostatus": false,  
> "complete": "false",  
> "statusVal": "",  
> "statusType": "auto",  
> "x": 560,  
> "y": 100,  
> "wires":   
> },  
> {  
> "id": "e7c6b6e59db57194",  
> "type": "mysql-r2",  
> "z": "595824d334f50ad0",  
> "name": "bme680\_v2 DB mysql-r2",  
> "host": "127.0.0.1",  
> "database": "bme680\_v2",  
> "username": "root",  
> "password": "mariadb.",  
> "sql": "",  
> "port": "3306",  
> "pooling": false,  
> "waitForConnections": true,  
> "connectionLimit": "10",  
> "queueTimeout": "10000",  
> "x": 570,  
> "y": 200,  
> "wires": [  
> [  
> "d55fcb955620b074"  
> ]  
> ]  
> },  
> {  
> "id": "cb73c6d3d323e94b",  
> "type": "debug",  
> "z": "595824d334f50ad0",  
> "name": "debug 4",  
> "active": true,  
> "tosidebar": true,  
> "console": false,  
> "tostatus": false,  
> "complete": "false",  
> "statusVal": "",  
> "statusType": "auto",  
> "x": 700,  
> "y": 320,  
> "wires":   
> },  
> {  
> "id": "47e7279e882583b2",  
> "type": "debug",  
> "z": "595824d334f50ad0",  
> "name": "timer out",  
> "active": false,  
> "tosidebar": true,  
> "console": false,  
> "tostatus": false,  
> "complete": "true",  
> "targetType": "full",  
> "statusVal": "",  
> "statusType": "auto",  
> "x": 320,  
> "y": 120,  
> "wires":   
> },  
> {  
> "id": "d55fcb955620b074",  
> "type": "debug",  
> "z": "595824d334f50ad0",  
> "name": "debug 5",  
> "active": true,  
> "tosidebar": true,  
> "console": false,  
> "tostatus": false,  
> "complete": "false",  
> "statusVal": "",  
> "statusType": "auto",  
> "x": 740,  
> "y": 160,  
> "wires":   
> },  
> {  
> "id": "9f53dada8eb45390",  
> "type": "mysql",  
> "z": "595824d334f50ad0",  
> "mydb": "fe6d1b3da8c52fe3",  
> "name": "mysql",  
> "x": 510,  
> "y": 280,  
> "wires": [  
> [  
> "cb73c6d3d323e94b"  
> ]  
> ]  
> },  
> {  
> "id": "fe6d1b3da8c52fe3",  
> "type": "MySQLdatabase",  
> "name": "mysql",  
> "host": "127.0.0.1",  
> "port": "3306",  
> "db": "bme680\_v2",  
> "tz": "",  
> "charset": "UTF8"  
> }  
> ]

> Blockquote  
> I'm using mariadb with the same function node.  
> I would like to use the latest and great but it fails  
> Thanks

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [12 August 2024 16:58 UTC](https://discourse.nodered.org/t/connection-to-database-via-node-mysql-r2-does-not-work-but-connection-with-node-mysql-does/90130/2 "2024-08-12T16:58:42Z")

</div>

node-red-node-mysql was updated 8 months ago, was downloaded 1300 times in the past week and is maintained by two chaps knolleary and dceejay (I think they are well known in the Node-red community).

No disrespect to nickyvaughn but his node-red-mysql-r2 was last updated 16 months ago and was downloaded 130 times in the last week.

You are backing the wrong horse!

---

<div class="post-metadata">

**Author:** ![chuckf201](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chuckf201/32/91382_2.png) [@chuckf201](https://discourse.nodered.org/u/chuckf201)\
**Post date:** [12 August 2024 17:01 UTC](https://discourse.nodered.org/t/connection-to-database-via-node-mysql-r2-does-not-work-but-connection-with-node-mysql-does/90130/3 "2024-08-12T17:01:01Z")

</div>

jbudd - thanks. You saved me hours of headache.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [12 August 2024 17:05 UTC](https://discourse.nodered.org/t/connection-to-database-via-node-mysql-r2-does-not-work-but-connection-with-node-mysql-does/90130/4 "2024-08-12T17:05:49Z")

</div>

It doesn't help you choose that node-red-mysql has 3.4 stars while node-red-mysql-r2 has 5 🤨

---

<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:** [11 October 2024 17:06 UTC](https://discourse.nodered.org/t/connection-to-database-via-node-mysql-r2-does-not-work-but-connection-with-node-mysql-does/90130/5 "2024-10-11T17:06:26Z")

</div>

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