# Log MQTT to MySQL

**URL:** <https://discourse.nodered.org/t/log-mqtt-to-mysql/11806>\
**Category:** General\
**Created:** [3 June 2019 19:36 UTC](https://discourse.nodered.org/t/log-mqtt-to-mysql/11806 "2019-06-03T19:36:25Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [4 June 2019 18:47 UTC](https://discourse.nodered.org/t/log-mqtt-to-mysql/11806/21 "2019-06-04T18:47:35Z")

</div>

> [@lozzer65](#):
>
> Trying the idea of deleting the package-lock.json. Struggling to find that file. This whats found when doing a search.

Do you know which folder is your "userDir"? It is normally `~/.node-red`. Check in that folder to see if you have a package-lock.json and delete that if you do. That is also the folder that you need to use to install packages manually using npm.

> [@lozzer65](#):
>
> Colin what was the fix for your suggestion please

The fix was to regress back to a known good version of uibuilder. However, that isn't relevant here. This was a different issue that I was able to reproduce and is fixed by installing v3.0.3 of node-red-contrib-moment. When I tried doing that, I had an issue which I resolved by deleting the package-lock file (which regularly seems to cause issues according to the various blogs and forums) and deleting the whole `~/.node-red/node_modules` folder then doing `npm install` from the `~/.node-red` folder.

---

<div class="post-metadata">

**Author:** ![lozzer65](https://avatars.discourse-cdn.com/v4/letter/l/f475e1/32.png) [@lozzer65](https://discourse.nodered.org/u/lozzer65)\
**Post date:** [4 June 2019 21:08 UTC](https://discourse.nodered.org/t/log-mqtt-to-mysql/11806/22 "2019-06-04T21:08:08Z")

</div>

Heres my mysql setup at home. Have had to use phpmyadmin as workbench will not install.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/c2ea1cb62d027697e07be472e70e598ac7d566de.png)

---

<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:** [5 June 2019 07:36 UTC](https://discourse.nodered.org/t/log-mqtt-to-mysql/11806/23 "2019-06-05T07:36:26Z")

</div>

The mysql question was what is the type of the timestamp column in the database on each system? That depends on how you created the table in the first place.

---

<div class="post-metadata">

**Author:** ![baqwas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/baqwas/32/106_2.png) [@baqwas](https://discourse.nodered.org/u/baqwas)\
**Post date:** [11 June 2019 14:13 UTC](https://discourse.nodered.org/t/log-mqtt-to-mysql/11806/24 "2019-06-11T14:13:44Z")

</div>

Hello!

Sorry, I'm late to the party here. (Latched on this thread via the summary that was sent to me since I had not logged on for a while)

My basic suggestion is to let MySQL generate the value for the _timestamp_ column (if it works for you). Then retrieve the value and adjust your code accordingly. The suggestion may appear to be impractical because every millisecond may matter for your projects. But that was my approach until I had a handle on timestamp data exchange formats between MariaDB and LibreOffice apps.

Kind regards.

---

<div class="post-metadata">

**Author:** ![lozzer65](https://avatars.discourse-cdn.com/v4/letter/l/f475e1/32.png) [@lozzer65](https://discourse.nodered.org/u/lozzer65)\
**Post date:** [11 June 2019 16:45 UTC](https://discourse.nodered.org/t/log-mqtt-to-mysql/11806/25 "2019-06-11T16:45:39Z")

</div>

Thanks baqwas, I got it working using the moment node, and also started playing with influxdb. It's been a steep learning curve, very much helped by all you guys.

Thanks  
Laurie

[Previous page](https://discourse.nodered.org/t/log-mqtt-to-mysql/11806.md?page=1)
