8 Magicbox external database setup
MagicBot edited this page 3 years ago

Setting up an external database for use with MagicBox

The MagicBox is a transient thing; it lasts only until the container is stopped. Users must configure an external database if they wish for their world to persist.

For utility we will use a MySQL container for this purpose. The assumtption is made that mysql-client is installed on the host machine.

$ docker pull mysql:latest

Spin up our new mysql server. Choose your own root password here.

$ docker run --name mysql -p 3306:3306 -v mysql_volume:/var/lib/mysql/ -d -e "MYSQL_ROOT_PASSWORD=ROOTPASS" mysql

Copy the mb.data/magicbanesql.conf file making the following edits.

  • Set your own password
  • Change localhost to the wildcard. (Allows remote access)
SET GLOBAL log_bin_trust_function_creators = 1;
CREATE USER 'magicbox'@'%' IDENTIFIED BY 'YOURPASSHERE';
CREATE DATABASE magicbane;
GRANT ALL PRIVILEGES ON *.* TO 'magicbox'@'%';
FLUSH PRIVILEGES;

Excute these instructions on the new mysql server

$ mysql -u root -p < mbremotesql.conf

Now log onto your Magicbox instance and dump the database with ./mbdump.sh

Move that file onto the host either via mb.conf or docker cp. Restore the database to your new mysql instance.

$ mysql -u magicbox -p < mbdump.sql

Edit a copy of magicbane.conf file reflecting your new database settings and place inside the shared ~/mb.conf folder on the host.

# Database configuration settings.  The supplied
# internal MySQL server is ephemeral!

MB_DATABASE_ADDRESS="localhost"
MB_DATABASE_PORT="3306"
MB_DATABASE_NAME="magicbane"
MB_DATABASE_USER="magicbox"
MB_DATABASE_PASS="ArtyomWasHere"

Restart your container.

tail console_login

You should see the login server booting from your new external database. Your world will now for to persist!