Deploy MySQL on Raspberry Pi3 via Pantacor Hub

Pantavisor and Pantacor Hub enable product makers to manage and update embedded devices. Pantavisor is the framework for containerized embedded Linux development. It connects devices and containerizes the embedded firmware user-land as well as any apps that you want to run on the device. In this tutorial, we show you how to install Pantavisor on a Raspberry Pi3, claim your device and make it available in the Pantacor Hub. Then we’ll show you how to deploy MySQL onto the device and connect to it with your laptop.

Prepare your Raspberry Pi 3 device for MySQL

Step 1: Flash the RPi3 initial stable image onto your SD card.

Download RPI3 image:

Click to download

unzip the device image with:

$ unxz rpi3_initial_stable.img.xz

Write the image onto the SD card using Raspberry Pi Imager

Step 2: Boot your RPI3

Insert your SD card and attach the power supply.

Step 3: Sign up to Pantacor Hub

Step 4: Download and install a CLI tool “pvr”

Note: pvr is a CLI which is used to interact with your device through the Pantacor hub platform. With pvr, you can easily share and revision your firmware and projects as if it were git tree. After downloading, move the pvr binary into your bin folder.

Linux(AMD64): Download Linux(ARM32v6): Download Darwin(AMD64): Download

pvr clone; pvr commit; pvr post

To install from github source code:

$ go get gitlab.com/pantacor/pvr
$ go build -o ~/bin/pvr gitlab.com/pantacor/pvr

Note: You need “GOLANG” to be installed in your system for building pvr from github source code.

Step 5: Detect & Claim your device:

Connect a LAN cable between your RPI3 and your computer or router.

Open your terminal and run

$ pvr device scan

Claim your device

$ pvr claim -c merely-regular-gorilla https://api.pantahub.com:443/devices/5f1b9c44e193a5000afa9901

Log into https://hub.pantacor.com/login and check for the newly claimed device in the dashboard.

Step 6: Clone the device to your computer using the Clone URL of your device

$ pvr clone https://pvr.pantahub.com/sirinibin/presently_learning_pelican/0 presently_learning_pelican

Now your device is ready to deploy your Mysql app

Deploy MySQL to the device by following 3 Steps

Step 1: Add “mySQL” to the device and deploy the change

Add MySQL:

$ pvr app add mysql --from=yobasystems/alpine-mariadb:arm32v7 --config-json=<(echo -n -e '{
"Env": [
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "MYSQL_DATABASE=testdb",
  "MYSQL_USER=testuser",
  "MYSQL_PASSWORD=123",
  "MYSQL_ROOT_PASSWORD=123",
  "MYSQL_CHARSET=utf8",
  "MYSQL_COLLATION=utf8_general_ci"
]
}')

Deploy the changes

 $ pvr add .
 $ pvr commit
 $ pvr post

Step 2: Access MySQL through Shell

mysql -u root -p123 -h 10.42.0.231

Step 3: Access MySQL through a dashboard app called “adminer”

Adminer is a dashboard app that can be used to visually manage the mysql database

By default Adminer is served through port 8080

Add adminer:

pvr app add adminer —from=arm32v7/adminer

Deploy the changes

 $ pvr add .
 $ pvr commit
 $ pvr post

Access adminer dashboard through http://10.42.0.231:8080/

Log into the Adminer dashboard with following MySQL credentials:

 Server:10.42.0.231
 Username:root
 Password:123

Now you can easily Create/update/delete mysql databases/tables through Adminer

You are Done!

 

Final Thoughts

In this tutorial, we described how to deploy a containerized version of MySQL and Adminer onto your Pantavisor-enabled device. Pantavisor doesn’t run Docker containers natively, but it does use Docker images as a great source of root file systems for containers that are run by the Pantavisor with LXC.

Take a deeper dive into managing Pantavisor Linux on your device locally with our front-end utilities Pantabox. 

We’re really excited for you to try Pantabox and Pantavisor Linux and we’d love to hear your thoughts. Try one of the guides or join us in the Pantavisor community forum.

Share:

Share on facebook
Share on twitter
Share on linkedin