Search code examples
mysqlnode-red

How can I connect a local MySQL database to the IBM Node-Red platform


I am using MySQL workbench on windows, which I want to connect to a Node-Red running on the IBM cloud. Since I don't run them on the same server the host 127.0.0.1 and port 3306 does not seem to work. What permissions should I give?


Solution

  • I'm going to make a LOT of assumptions here, because there really isn't enough information in your question.

    First assumption, by "running on IBM" you mean that Node-RED is running on the IBM Cloud hosting service.

    The short answer is you can not do what you want.

    The longer version is that you probably could actually make this work but doing it is a REALLY bad idea.

    Second assumption, you are doing this from home (even if you are doing it from a office location the same problems are likely to apply). This means you are connected to a local LAN using RFC 1918 address range (e.g. 192.168.0.x), this means you are behind a router that is performing NAT (Network Address Translation). This means you are going to need to set up portforwarding on the router so that when traffic arrives at the router it will send it on to your Windows machine. How you do this will depend on your router.

    Next problem, your broadband probably doesn't have a static IP address which means it will change every time your connection drops. There are work arounds for this using things like Dynamic DNS. But that's too complicated to get into here.

    Assuming you get all of that sorted out you still have the problem that you have now exposed your mysql database to the internet, so you need to make sure you have enabled all the right security measures to prevent people logging in and at best seeing all your data.

    There are 2 much better solutions to this

    1. Run Node-RED on the same machine or at least on the same local network as the database.

    2. Use one of IBM Clouds hosted database solutions, these are a lot easier to connect to a IBM Cloud instance of Node-RED.