a very small docker image base on alpine with MySQL/MariaDB
docker build -t wangxian/alpine-mysql:latest .
cp .env-dist .env
vim build .env # change environment if you need
docker compose build
# only root user
docker run -it --name mysql -p 3306:3306 -v ~/appdata/mysql:/app/mysql -e MYSQL_DATABASE=admin -e MYSQL_ROOT_PASSWORD=s6321..8 wangxian/alpine-mysql
# use normal user of app
docker run -it --name mysql -p 3306:3306 -v ~/appdata/mysql:/app/mysql -e MYSQL_DATABASE=admin -e MYSQL_USER=app -e MYSQL_PASSWORD=app123..8 -e MYSQL_ROOT_PASSWORD=s6321..8 wangxian/alpine-mysql
docker-compose up -d
It will:
- set no password for 'root' with localhost connections;
- set password for 'root' with non-localhost connection
- create a new db
- create an normal user and set his password for non-localhost connections