• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] MySQL Container / Server in another Container?
is it possible to run a mysql server on the netpi?
I thought it should be possible to install it in another container, but i'm always getting some errors.
In my case, its kinda difficult to understand how to install the hypriot/rpi-mysql without having a command line..
If its possible - how to connect to it from another container? (write data from node-red in a table)

best regards 
Hello Paul,

yes this is possible. And the idea to let it run in a separate container is also great.

I read the documentation of the MySQL server you are referencing at https://hub.docker.com/r/hypriot/rpi-mysql/. And I can agree that using this container will work.

But there are some things you need to take care about using netPI. The documentation declares everything based on using a command line as you have recognized. This is of course not possible with netPI. So the documentation says you have to define a password with the "-e MYSQL_ROOT_PASSWORD=my-secret-pw" command. This command can be replaced in netPI using the option "env" in the advanced container menu then using at least "MYSQL_ROOT_PASSWORD" as name and "your password" as value. But if you read on the documentation there are other env variables too you can set additionally.

Then of course you have to take care about the port 3306 that is used by this container. This port needs to be exposed when you start the container from port 3306 to port 3306 using the default network/bridge mode.

The documentation says also that another container that wants to access to this MySQL server needs to run the docker command "--link some-mysql:mysql". But as you can read it here https://docs.docker.com/network/links/ the "link" command shall not be used any more. This is why I would do it differently. I would give your container a "hostname" in the network setting dialog for example "paulmysql". Then this container within netPI will get of course an internal IP address but also a name that is constant you can address from other containers.

So from your container then you can use a python script like this:

import MySQLdb

db = MySQLdb.connect(host="paulmysql",    # your host, usually localhost
                     user="username",         # your username
                     passwd="password",  # your password
                     db="databasename")        # name of the data base

Hope this helps.
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

Thank you, it is much easier when i know where to put the start commands Smile

Possibly Related Threads...
Thread Author Replies Views Last Post
  Exporting and importing container images Armin@netPI 3 38 May-20th-2020, 11:24 AM
Last Post: COswald
  how to pick up PROFINET data and store them to OPC UA server on Node-RED/netPI. tad 7 34 March-16th-2020, 10:21 AM
Last Post: Armin@netPI
Exclamation Creating a container Linnerz 6 39 March-6th-2020, 02:47 PM
Last Post: Armin@netPI
  PM - develope OPC UA Server using the Codesys Lingyue 5 23 January-17th-2020, 11:12 AM
Last Post: Armin@netPI
  [SOLVED] activate LED1/2 with Node-RED + fieldbus nodes container Christian_Rau 6 97 October-21st-2019, 10:30 AM
Last Post: Armin@netPI
  Cannot start container Magnus 7 43 October-16th-2019, 01:00 PM
Last Post: Armin@netPI
  Generate VLAN interfaces in container FrankJacob 7 46 September-26th-2019, 03:19 PM
Last Post: Armin@netPI
  create container in Portainer v1.12.4 dcatteeu 2 26 September-9th-2019, 12:12 PM
Last Post: dcatteeu
  UMTS/LTE support via USB router/modem sticks in a container Armin@netPI 3 159 September-5th-2019, 02:07 PM
Last Post: Armin@netPI
  Ready-to-deploy: full featured Node-RED container Armin@netPI 5 86 July-25th-2019, 06:16 AM
Last Post: Armin@netPI

Forum Jump:

Users browsing this thread: 1 Guest(s)