Home Installing MySQL or MariaDB in Docker
Post
Cancel

Installing MySQL or MariaDB in Docker

MySQL and MariaDB are essentially interchangeable.

MySQL is the largest open source database community. MariaDB is a fork from MySQL and is 100% compatible with prior versions of MySQL. However, while the charter for MariaDB remains open source and cross-platform, the future is unclear for MySQL. Oracle prioritizes their proprietary products over MySQL, making marginal advancements between MySQL 5.7 (joining 5.6 as End of Support in 2023) and MySQL 8, and promoting Oracle Cloud and Heatwave, pairing a proprietary platform on a proprietary cloud.

This script will create a stateful instance, meaning it can be stopped or restarted without losing data.

1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash

# Pick your database engine.
#DB_image="mariadb"
DB_image="mysql"

mkdir database-files
mkdir -p etc-mysql/conf.d

docker run -d --name "${DB_image}test" -e MYSQL_ROOT_PASSWORD=mypass -p 3306:3306 `
-v ${PWD}/database-files:/var/lib/mysql -v ${PWD}/etc-mysql:/etc/mysql "$DB_image"
This post is licensed under CC BY 4.0 by the author.