Skip to content

MySQL configuration example

About MySQL

MySQL is the world's most popular open source database. Whether you are a fast growing web property, technology ISV or large enterprise, MySQL can cost-effectively help you deliver high performance, scalable database applications.

More information about MySQL

How to add MySQL 8 to Qlico?

Add the following YAML to the services section of your docker-compose.yaml file.

  mysql8:
    image: mysql:8.0.32
    container_name: qlico-core_mysql8
    restart: unless-stopped
    logging:
      driver: none
    ports:
      - 3308:3306
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-qlico}
    volumes:
      - mysql-data8:/var/lib/mysql
    networks:
      - qlico-core

Add the following YAML to the volumes section of your docker-compose.yaml file.

  mysql-data8:
    name: qlico-core_mysql8-data
    driver: local

Example in a full docker-compose file

This is a large example, so you know where to place the MySQL service and volume.

---
# Author: Qlico <hello@qlico.dev>
version: "3.9"
services:
  traefik:
    image: traefik:v2.8
    container_name: qlico-core_traefik
    command: [ '--providers.docker', '--api.insecure' ]
    networks:
      - qlico-core
    ports:
      - 80:80
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    labels:
      - "traefik.http.routers.traefik.rule=Host(`traefik.qlico`)"
      - "traefik.http.services.traefik.loadbalancer.server.port=8080"
  mysql8:
    image: mysql:8.0.32
    container_name: qlico-core_mysql8
    restart: unless-stopped
    logging:
      driver: none
    ports:
      - 3308:3306
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-qlico}
    volumes:
      - mysql-data8:/var/lib/mysql
    networks:
      - qlico-core
volumes:
  mysql-data8:
    name: qlico-core_mysql8-data
networks:
  qlico-core:
    driver: bridge
    name: qlico-core

How to add MySQL 5 to Qlico?

Add the following YAML to the services section of your docker-compose.yaml file.

  mysql5:
    image: mysql:5.7.39
    container_name: qlico-core_mysql5
    logging:
      driver: none
    ports:
      - 3305:3306
    environment:
      MYSQL_USER: ${MYSQL_USERNAME:-root}
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-qlico}
    volumes:
      - mysql-data5:/var/lib/mysql
    networks:
      - qlico-core

Add the following YAML to the volumes section of your docker-compose.yaml file.

  mysql-data5:
    name: qlico-core_mysql5-data
    driver: local

Example in a full docker-compose file

This is a large example, so you know where to place the MySQL service and volume.

---
# Author: Qlico <hello@qlico.dev>
version: "3.9"
services:
  traefik:
    image: traefik:v2.8
    container_name: qlico-core_traefik
    command: [ '--providers.docker', '--api.insecure' ]
    networks:
      - qlico-core
    ports:
      - 80:80
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    labels:
      - "traefik.http.routers.traefik.rule=Host(`traefik.qlico`)"
      - "traefik.http.services.traefik.loadbalancer.server.port=8080"
  mysql5:
    image: mysql:5.7.39
    container_name: qlico-core_mysql5
    logging:
      driver: none
    ports:
      - 3305:3306
    environment:
      MYSQL_USER: ${MYSQL_USERNAME:-root}
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-qlico}
    volumes:
      - mysql-data5:/var/lib/mysql
    networks:
      - qlico-core
    driver: local
volumes:
  mysql-data5:
    name: qlico-core_mysql5-data
networks:
  qlico-core:
    driver: bridge
    name: qlico-core