Turn-key MySQL environment for rapid app development, complete with persistent storage, seed data, backup/restore scripts, and phpMyAdmin UI.
This repo is designed to be cloned into any new project or used standalone as part of a monorepo of services.
.
├── .env
├── docker-compose.yml
├── mysql/
│ └── init/ # Optional SQL seed scripts (.sql run on container init)
├── scripts/
│ ├── reset-mysql.sh # Reset containers & volumes
│ ├── backup-mysql.sh # Backup DB to ./backups
│ └── restore-mysql.sh # Restore DB from SQL dump
└── backups/ # DB backups stored here
Create .env
in the project root:
# MySQL
MYSQL_CONTAINER_NAME=mysql-dev
MYSQL_VERSION=8.4
MYSQL_DATABASE=appdb
MYSQL_USER=appuser
MYSQL_PASSWORD=apppassword
MYSQL_ROOT_PASSWORD=rootpassword
MYSQL_PORT=3306
# phpMyAdmin
PHPMYADMIN_CONTAINER_NAME=phpmyadmin-dev
PHPMYADMIN_PORT=8081
# Start containers
docker compose up -d
# Stop containers
docker compose down
# Reset (stop, wipe volumes, rebuild)
./scripts/reset-mysql.sh
All scripts live in ./scripts/ and must be executable (chmod +x ./scripts/*.sh).
./scripts/reset-mysql.sh
./scripts/backup-mysql.sh
Creates timestamped .sql dumps in ./backups.
./scripts/restore-mysql.sh backups/mysql_dump_20240101_120000.sql
mysql -h 127.0.0.1 -P 3306 -u appuser -p
👉 http://localhost:8081
Login with:
- User:
${MYSQL_USER}
- Password:
${MYSQL_PASSWORD}
- Root access also available with
${MYSQL_ROOT_PASSWORD}
.
graph TD
subgraph Docker Network
A[phpMyAdmin
:8081] <--> B[MySQL
:3306]
end
C[Host Machine] -->|Browser| A
C -->|mysql client / apps| B
- MySQL 8.4 LTS (latest stable)
- phpMyAdmin UI for browsing
- Environment-driven config
- Seed data via ./mysql/init
- Persistent storage
- Reset, Backup, and Restore scripts