Overview
This template provides a production‑ready MySQL instance as a Monk runnable. You can:- Run it directly to get a managed MySQL container with sensible defaults
- Inherit it in your own runnable to seamlessly add a relational database to your stack
What this template manages
- MySQL container (
mysqlimage, configurable tag) - Network service on port 3306
- Persistent volumes for data storage
- Optional initialization of database, user, and passwords
Quick start (run directly)
- Load templates
- Run MySQL with defaults
- Customize credentials (recommended via inheritance)
variables. Secrets added with monk secrets add will not affect this runnable unless you inherit it and reference those secrets.
- Preferred: inherit and replace variables with
secret("...")as shown below. - Alternative: fork/clone and edit the
variablesinmysql/mysql.yml, thenmonk load MANIFESTand run.
localhost:3306 (or the runnable hostname inside Monk networks) using the configured credentials.
Configuration
Key variables you can customize in this template:${monk-volume-path}/mysql on the host.
Use by inheritance (recommended for apps)
Inherit the MySQL runnable in your application and declare a connection. Example:Ports and connectivity
- Service:
mysqlon TCP port3306 - From other runnables in the same process group, use
connection-hostname("\<connection-name>")to resolve the DB host.
Persistence
- Data path:
${monk-volume-path}/mysql:/var/lib/mysql - MySQL stores all databases and tables in this directory
Related templates
- High‑availability setup: see the
mysql-leader-follower/template in this repository for a leader-follower replication setup. - Load balancing: see the
mysql-leader-follower-proxysql/template for leader-follower replication with ProxySQL.
Troubleshooting
- If you changed
mysql-root-passwordbut the container has existing data, authentication may fail. Either reset the data volume or update the password inside the DB to match. - Ensure the host volumes are writable by the container user.
- Check logs: