MySQL Manager
Manages the shared MySQL Docker container used by local dev instances.
Architecture
mysql-manager/
├── docker-compose.yml # MySQL 8.0 container
└── run.sh # lifecycle + db admin CLI
The MySQL container runs on the shared Docker network (nginx-proxy_net by default), making it accessible to all app containers by hostname (codai_db). Data is persisted in a named volume (mysql_data).
Commands
./run.sh start # start MySQL container
./run.sh stop # stop container (data persists in volume)
./run.sh status # container status + list databases
./run.sh wait # block until MySQL is ready (for scripts)
./run.sh create-db <name> # CREATE DATABASE IF NOT EXISTS
./run.sh drop-db <name> # DROP DATABASE (interactive confirm)
./run.sh dump <src> <dest> # mysqldump src | mysql dest
./run.sh list-dbs # SHOW DATABASES (filtered)
How to Execute Tasks
Start MySQL for the first time
cd mysql-manager && ./run.sh start
On first run, Docker creates the volume and initializes codai_main.
Create a database for a new instance
./run.sh create-db codai_alpha
Snapshot main database into a new instance
./run.sh dump codai_main codai_alpha
Remove a worktree database
./run.sh drop-db codai_alpha # prompts for confirmation
Check status
./run.sh status
Startup Order
Start MySQL before starting any app instances:
proxy-manager:./run.sh start(creates the shared Docker network)mysql-manager:./run.sh start(joins the shared network)worktree-manager:./run.sh start <instance>
Configuration
Set via environment variables or a .env file in mysql-manager/:
| Variable | Default | Purpose |
|---|---|---|
MYSQL_CONTAINER | codai_db | Container name |
MYSQL_ROOT_PASS | secret | MySQL root password |
MYSQL_MAIN_DB | codai_main | Primary database name |
MYSQL_PORT | 3307 | Host port (maps to 3306) |
CODAI_NETWORK | nginx-proxy_net | Shared Docker network name |
Rules
- Never drop
MYSQL_MAIN_DB— it is the source of truth for snapshots. - The
drop-dbcommand always prompts for confirmation. stoppreserves data in the Docker volume. Usedocker compose down -vonly to wipe data intentionally.- The container name (
codai_db) is the hostname used by backend apps to connect.
Related Plugins
proxy-manager— manages the nginx-proxy that routes traffic to app instances (start this first)worktree-manager— manages app instances and git worktrees (depends on this plugin)