• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] MySQL Container / Server in another Container?
#1
Hello,
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 
paul
  Reply
#2
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:

#!/usr/bin/python
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)

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  netPI opc ua server pull image error wswitula 3 3,114 August-27th-2021, 10:47 AM
Last Post: wswitula
  OPC UA server with NetPi RTE DSongra 9 4,213 July-27th-2021, 12:01 PM
Last Post: Armin@netPI
  REST API server data communication MGharat 2 2,442 July-21st-2021, 07:01 AM
Last Post: MGharat
  TOSILOCK for CONTAINER COswald 3 2,192 July-13th-2021, 11:32 AM
Last Post: Armin@netPI
  [SOLVED]DHCP server not working m-yoshikawa 24 13,629 June-11th-2021, 07:04 AM
Last Post: tad
  Access to RTC from my own container application tad 1 3,525 March-19th-2021, 02:58 PM
Last Post: Armin@netPI
  [SOLVED] Starting services/commands/scripts at startup of a container Jonas.Sellmann@outlook.de 9 6,046 March-9th-2021, 08:47 AM
Last Post: WalterSchaefer
  MySQL database DSongra 6 3,371 January-7th-2021, 05:34 AM
Last Post: Armin@netPI
  OpenVPN container Armin@netPI 0 1,618 January-3rd-2021, 12:13 PM
Last Post: Armin@netPI
  operating Console of a container on netPI connected to Wi-Fi tethering tad 3 2,620 December-3rd-2020, 12:32 PM
Last Post: tad

Forum Jump:


Users browsing this thread: 1 Guest(s)