# Mysql lost connection after INSERT

**URL:** <https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325>\
**Category:** General\
**Created:** [18 June 2021 10:45 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325 "2021-06-18T10:45:20Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![AK51](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ak51/32/8438_2.png) [@AK51](https://discourse.nodered.org/u/AK51)\
**Post date:** [18 June 2021 10:45 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325/1 "2021-06-18T10:45:21Z")

</div>

Hi, I have played with mysql and it worked before last year.  
However, last week, I create a simple flow and the the node-red crash after the INSERT. I have tried in a win-32 system and raspberry pi system, same problem.  
Please take a look of the video. I assume the mysql 0.1.9 may have problem? How to downgrade the version? Thx

[![](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/5/257b1258dfde30a1c7aa316f25fb5f3e730366eb.jpeg "mySQL kill node-red after INSERT?") ](https://www.youtube.com/watch?v=-gBku_g6tig)

---

<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:** [18 June 2021 10:50 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325/2 "2021-06-18T10:50:06Z")

</div>

we really need to see the beginning part of the error in the console not the end. so can you just cut/paste the console log here rather than attach a video.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [18 June 2021 11:01 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325/3 "2021-06-18T11:01:27Z")

</div>

I use a number of the MySQL nodes, same version as yours 0.1.9 without any problem on a RPI-4B.  
The database is on a remote server in London, UK.

Here are some screen-shots for an INSERT using a 'template' node to format the query for data collected, via MQTT, from a set of infrared detectors.

 ![Screen Shot 06-18-21 at 11.49 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/2/e2abbb7dcad9b59aec080cb0ab4c8e45ea8e796e.jpeg)  
 ![Screen Shot 06-18-21 at 11.50 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/0/10b79db32e1992d96c078a016ce68f3d45a72490.jpeg)  
 ![Screen Shot 06-18-21 at 11.51 AM 001](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/9/f9b821c0e66181d3d024cb78bac5ddada54fd31f.jpeg)  
 ![Screen Shot 06-18-21 at 11.51 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/a/ea9d1ebdb78e9fc06f3cdecd5d099d07e1f7d843.jpeg)

---

<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:** [18 June 2021 11:16 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325/4 "2021-06-18T11:16:01Z")

</div>

@AK51 as I asked you in the thread I closed (as it was two years old  
what version of NR and node.js?  
what device is running NR?  
what device is running mysql?  
what version of mysql?  
what is showing in the NR log (do a copy and paste)  
a copy of your flow.

---

<div class="post-metadata">

**Author:** ![AK51](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ak51/32/8438_2.png) [@AK51](https://discourse.nodered.org/u/AK51)\
**Post date:** [19 June 2021 03:02 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325/5 "2021-06-19T03:02:40Z")

</div>

Hi all,  
Here is a similar video with more details. For the Time\_Stamp and laser column, both are VARCHAR(45). Thx

[![](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/5/857e592a4f859af098df4e2ffa77627e863fc2ba.jpeg "Node Red MySQL disconnect") ](https://www.youtube.com/watch?v=nPXUmNVeGvs)

///////////////////////////////////////////////////////////////////////////////////////////////////////  
LOG msg  
///////////////////////////////////////////////////////////////////////////////////////////////////////  
19 Jun 10:50:32 - [info] Starting flows  
19 Jun 10:50:33 - [info] Started flows  
19 Jun 10:50:39 - [red] Uncaught Exception:  
19 Jun 10:50:39 - TypeError: done is not a function  
at Query. (/home/pi/.node-red/node\_modules/node-red-node-mysql/68-mysql.js:177:29)  
at Query. (/home/pi/.node-red/node\_modules/mysql/lib/Connection.js:526:10)  
at Query.\_callback (/home/pi/.node-red/node\_modules/mysql/lib/Connection.js:488:16)  
at Query.Sequence.end (/home/pi/.node-red/node\_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)  
at Query.\_handleFinalResultPacket (/home/pi/.node-red/node\_modules/mysql/lib/protocol/sequences/Query.js:149:8)  
at Query.OkPacket (/home/pi/.node-red/node\_modules/mysql/lib/protocol/sequences/Query.js:74:10)  
at Protocol.\_parsePacket (/home/pi/.node-red/node\_modules/mysql/lib/protocol/Protocol.js:291:23)  
at Parser.\_parsePacket (/home/pi/.node-red/node\_modules/mysql/lib/protocol/Parser.js:433:10)  
at Parser.write (/home/pi/.node-red/node\_modules/mysql/lib/protocol/Parser.js:43:10)  
at Protocol.write (/home/pi/.node-red/node\_modules/mysql/lib/protocol/Protocol.js:38:16)  
at Socket. (/home/pi/.node-red/node\_modules/mysql/lib/Connection.js:88:28)  
at Socket. (/home/pi/.node-red/node\_modules/mysql/lib/Connection.js:526:10)  
at Socket.emit (events.js:189:13)  
at addChunk (\_stream\_readable.js:284:12)  
at readableAddChunk (\_stream\_readable.js:265:11)  
at Socket.Readable.push (\_stream\_readable.js:220:10)  
pi@ubuntu:~ $

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [19 June 2021 03:06 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325/6 "2021-06-19T03:06:40Z")

</div>

> [@AK51](#):
>
> TypeError: done is not a function  
> at Query. (/home/pi/.node-red/node\_modules/node-red-node-mysql/68-mysql.js:177:29)

This is a good clue. `done()` is a newer node-red feature.

What version of node-red are you running?

---

<div class="post-metadata">

**Author:** ![AK51](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ak51/32/8438_2.png) [@AK51](https://discourse.nodered.org/u/AK51)\
**Post date:** [19 June 2021 03:38 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325/7 "2021-06-19T03:38:18Z")

</div>

The node red version is v0.20.8

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [19 June 2021 03:57 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325/8 "2021-06-19T03:57:51Z")

</div>

Ok, without looking at the source for node-red-node-mysql, I am fairly confident this is an oversight. You should raise an issue.

However, if you can upgrade node-red this problem will disappear.

---

<div class="post-metadata">

**Author:** ![AK51](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ak51/32/8438_2.png) [@AK51](https://discourse.nodered.org/u/AK51)\
**Post date:** [19 June 2021 04:05 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325/9 "2021-06-19T04:05:34Z")

</div>

I have updated the node-red and it is ok now.  
I have also tried in the win32 system, it works too.  
Thx for everyone's help.  
Cheers. :\>

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [19 June 2021 04:28 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325/10 "2021-06-19T04:28:15Z")

</div>

It's worth reading the News channel to get info about the latest releases of Node-RED (and any issues).

> [@tada Node-RED 2.0.0-beta.1 Released](https://discourse.nodered.org/t/node-red-2-0-0-beta-1-released/46990):
>
> tada The first beta release of Node-RED 2.0.0 is now available. The [Change Log](https://github.com/node-red/node-red/blob/4acb66fb7a4c50ba237248ac61b20f0472526d08/CHANGELOG.md) has the full list of changes in this release, but here are the highlights. Note: if any issues are reported against the beta, we'll update this post to list them here. If you hit a problem, please do check back here before adding a comment. Known Issues HTTP Request node does not work properly with all HTTP proxies. Major Changes The main focus of this release is dropping support for old versions of Node.js. …

This is what you need to do to update to the latest release of Node-RED running on a Raspberry Pi.

 ![Screen Shot 06-19-21 at 05.25 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/4/94e4abbdf18918304fb1b80b7247f88e05745bf1.jpeg)

---

<div class="post-metadata">

**Author:** ![AK51](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ak51/32/8438_2.png) [@AK51](https://discourse.nodered.org/u/AK51)\
**Post date:** [19 June 2021 04:31 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325/11 "2021-06-19T04:31:41Z")

</div>

I did the upgrade and the version is v1.3.4.  
Anyway, it works now. Thx

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [19 June 2021 04:32 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325/12 "2021-06-19T04:32:27Z")

</div>

Well done and thanks for letting us know.

EDIT: Did you include @next on the end of the command as my version of Node-RED is at 2.0.0beta1

![Screen Shot 06-19-21 at 05.33 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/c/bc3a9774190fa6bb6b61c18647df97ce9fdc435f.jpeg)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 June 2021 06:52 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325/13 "2021-06-19T06:52:32Z")

</div>

I don't think the next version is necessary to sort this problem, just the current release.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [19 June 2021 07:03 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325/14 "2021-06-19T07:03:04Z")

</div>

Yes I realise that - I was just pointing out that there is a later version availlable.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [19 June 2021 07:33 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325/15 "2021-06-19T07:33:54Z")

</div>

@dceejay regarding this issue...

> [@Steve-Mcl](#):
>
> > [@AK51](#):
> >
> > TypeError: done is not a function
> > 
> > > at Query. (/home/pi/.node-red/node\_modules/node-red-node-mysql/68-mysql.js:177:29)
> 
> This is a good clue. `done()` is a newer node-red feature

The op has confirmed updating node-red has solved his issue. This definitely looks like node-red-node-mysql isn't checking done before calling it. Just thought I'd tag you in case you missed this thread or the op doesn't raise an issue

---

<div class="post-metadata">

**Author:** ![AK51](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ak51/32/8438_2.png) [@AK51](https://discourse.nodered.org/u/AK51)\
**Post date:** [19 June 2021 08:49 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325/16 "2021-06-19T08:49:32Z")

</div>

By the way, I have a running node-red system in a remote area, it seems risky to upgrade the node-red version comparing with installing an older version of mysql node.  
Is it possible to install mysql node with lower version? There is no selection in UI, right?  
[https://nodered.org/docs/user-guide/editor/palette/manager](https://nodered.org/docs/user-guide/editor/palette/manager)

I have tried to install older version using this:  
I deleted all flow, and uninstall in mysql in manage palette  
npm install node-red-node-mysql@0.1.7  
restart the computer but the mysql is not there. May I know the proper procedure? Not sure if I did it right. I can try it again.  
Thx

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [19 June 2021 08:55 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325/17 "2021-06-19T08:55:51Z")

</div>

> [@AK51](#):
>
> Is it possible to install mysql node with lower version

Yes.

> [@AK51](#):
>
> I have tried to install older version using this:  
> I deleted all flow, and uninstall in mysql in manage palette  
> npm install node-red-node-mysql@0.1.7  
> restart the computer

You should have asked first - that was a fair bit OTT.

You simply needed to `cd` into the `.node-red` folder (that's important) then run `npm install node-red-node-mysql@0.1.7` then restart node-red.

---

<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:** [18 August 2021 08:56 UTC](https://discourse.nodered.org/t/mysql-lost-connection-after-insert/47325/18 "2021-08-18T08:56:05Z")

</div>

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