Skip to main content
The following guide will help you deploy the Minimus MySQL image with self-signed, locally issued certificates to help you get started. Run the code to try it for yourself.
For production purposes, we recommend using publicly trusted certificates issued by a Certificate Authority (CA).

Components

  • MySQL image built by Minimus: MySQL container configured with --require_secure_transport=ON for client authentication.
  • Dynamic certificate generation via OpenSSL:
    • certgen.sh script: Shell script that generates a custom CA, server, and client certificates using OpenSSL.
    • minidebug image: A Minimus dev toolkit that provides a shell, OpenSSL, and other utilities used to generate the certificates.

What this guide demonstrates

  • TLS handshake validation
  • Server/client certificate trust
  • Basic auth and MySQL operations
  • Image compatibility

Directory structure

Deploy MySQL with TLS certificates

Step 1: Generate TLS certificates

1

Save script that generates TLS certificates

Save the following script to a file named certgen.sh. The script is used to generate the TLS certificates and store them in a certs folder on the host. It sets UID 1000 as the owner of the certificate files to match the default user of the MySQL process inside the container.
certgen.sh
2

Save Docker Compose configuration

Save the following YAML file to run with Docker Compose. It uses the Minimus minidebug image to generate the certificates with the certgen.sh shell script. Minidebug is a Minimus dev toolkit that provides a shell, OpenSSL, and other utilities. The certificates will be persisted in the certs volume on the host.
create-certs.yml
3

Generate certificates

Run the following to generate the certificates:
Congrats! You have just generated the following self-signed certificates:
  • Self-signed CA certificate (ca.pem)
  • Server certificates (server-cert.pem, server-key.pem, server.csr)
  • Client certificates for testuser (client.csr, client.pem, client-cert.pem, client-key.pem)
Certificate permissions are adjusted to support non-root containers. In the next steps, we will mount these certificates into the MySQL container.

Step 2: Deploy MySQL server

1

Save Docker Compose script

Save the following Docker Compose script to a file named docker-compose.yml. This script sets up the MySQL service with a healthcheck, mounts a volume with the certificates, maps port 3306, and connects the container to a custom network:
docker-compose.yml
2

Run MySQL

Start the MySQL container:

Step 3: Test your MySQL server

Following are a few commands you can try out:
  1. Connect to the database:
    You should get a response from the server asking to input the password. If you used the compose file from this guide as is, the password is rootpass.
  2. Create a test database (for example my_new_db):
  3. List all databases:
  4. Show server version:
  5. Check that TLS is active:
    Some server options and system variables were recently deprecated, including --ssl, --skip-ssl, and --admin-ssl server options, and the have_ssl and have_openssl system variables. Learn more
Last modified on July 12, 2026