Skip to content

⭐ StartMysql

Terrence Daniels edited this page Jul 9, 2026 · 2 revisions

StartMysql StartMysql is the provisioning action responsible for launching MySQL database containers with secure defaults, predictable configuration, SSL support, persistent volumes, and engine‑specific runtime options. It is one of the core StartActions in the database provisioning system.

This page explains how StartMysql works, what it generates, and how it fits into the broader provisioning architecture.

Purpose of StartMysql The StartMysql action handles all logic required to start a MySQL instance, including:

Validating configuration

Generating SSL certificates

Creating persistent volumes

Building environment variables

Generating Docker Compose

Applying MySQL‑specific runtime flags

Configuring healthchecks

Starting the container

It ensures MySQL is provisioned consistently and securely across all deployments.

MySQL‑Specific Requirements MySQL requires several engine‑specific settings that differ from other databases:

  1. Root Password MySQL requires: MYSQL_ROOT_PASSWORD This is injected automatically based on the database configuration.

  2. Authentication Plugin To ensure compatibility with older clients, MySQL often requires: --default-authentication-plugin=mysql_native_password This runtime flag is added automatically.

  3. SSL/TLS Configuration If SSL is enabled, MySQL requires:

CA certificate

Server certificate

Server key

TLS configuration flags

These are generated and mounted automatically.

  1. Data Directory MySQL stores data in: /var/lib/mysql This directory is mapped to a persistent volume.

StartMysql Lifecycle The provisioning flow for MySQL follows a predictable sequence: flowchart TD A[StartMysql] --> B[Validate Configuration] B --> C[Generate SSL Certificates] C --> D[Generate Persistent Volumes] D --> E[Build Environment Variables] E --> F[Generate Docker Compose] F --> G[Start MySQL Container]

  1. Validate Configuration StartMysql checks:

Port availability

Root password

Volume paths

SSL settings

Custom runtime options

If any required configuration is missing, the action fails early.

  1. Generate SSL Certificates If SSL is enabled:

A CA certificate is generated

A server certificate is generated

A server key is generated

Certificates are mounted into the container

MySQL is configured to use TLS

Certificates are stored under: /data/coolify/ssl//

  1. Generate Persistent Volumes Using GeneratesLocalPersistentVolumes, StartMysql creates:

Local data directory

SSL directory

Config directory (if needed)

Volumes are mapped into the container: /var/lib/mysql /etc/mysql/ssl This ensures data persists across container restarts.

  1. Build Environment Variables StartMysql builds a complete environment variable set including:

Required MYSQL_ROOT_PASSWORD MYSQL_DATABASE MYSQL_USER MYSQL_PASSWORD

Optional User‑provided variables.

System Internal variables required for provisioning.

SSL If TLS is enabled: MYSQL_SSL_CA MYSQL_SSL_CERT MYSQL_SSL_KEY

  1. Generate Docker Compose StartMysql generates a full Compose service definition including:

Image mysql:

Ports 3306:3306

Volumes Data directory

SSL directory

Config directory

Environment Variables All normalized variables.

Healthcheck MySQL healthcheck typically uses: mysqladmin ping -h localhost

Runtime Options MySQL‑specific flags such as: --default-authentication-plugin=mysql_native_password

  1. Start the Container The generated Compose file is passed to the provisioning engine, which:

Creates the container

Applies resource limits

Connects networks

Starts MySQL

Verifies healthcheck

Marks the database as running

Example Compose Snippet (This is conceptual — your actual implementation generates this dynamically.) services: mysql: image: mysql:8.0 ports: - "3306:3306" environment: MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}" MYSQL_DATABASE: "${MYSQL_DATABASE}" MYSQL_USER: "${MYSQL_USER}" MYSQL_PASSWORD: "${MYSQL_PASSWORD}" volumes: - /data/coolify/mysql//data:/var/lib/mysql - /data/coolify/ssl/:/etc/mysql/ssl command: - --default-authentication-plugin=mysql_native_password healthcheck: test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] interval: 10s timeout: 5s retries: 5

Why StartMysql Is Important StartMysql ensures:

Secure defaults

Predictable provisioning

Engine‑specific behavior

SSL support

Persistent storage

Clean environment variable handling

Consistent Docker orchestration

It is the foundation of MySQL provisioning in your platform.

Clone this wiki locally