Skip to content

MS SQL

Setting Up MySQL on Docker Compose

MySQL is one of the most popular open-source relational database management systems (RDBMS), which is widely used for developing database-driven applications.

MySQL is a key part of the LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack, and it is favourited by developers for its speed, reliability and ease of use.

Why Choose MySQL

MySQL is an RDBMS that uses Structured Query Language (SQL) for accessing and managing the data in a database. It supports various types of data, complex queries, and transactions, making it a powerful tool for both small-scale applications and large-scale systems.

Key Features of MySQL:

  • Open Source - MySQL is open-source software, meaning it can be freely downloaded and used.
  • Cross-Platform - MySQL runs on various operating systems, including Windows, Linux and MacOS.
  • Scalability - MySQL supports large databases and can handle large amounts of data and traffic
  • Secuity - Provides robust security features, including authentication, data encryption, and access controls.
  • Support for Large Databases - MySQL can manage databases of several gigabytes in size and supports millions of rows in a table.

Mirosoft’s Support for MySQL

Microsoft offers a variety of tools, services and platforms to extend support for MySQL:

  • Azure Database for MySQL

    • Azure Database for MySQL is a managed service provided by Microsoft in their Azure Cloud Platform that allows MySQL to be run, managed and scaled in the cloud. The service takes care of routine database management tasks like backups, patches and monitoring which enables develops to focus application development.
  • SQL Server Management Assistant(SSMA) for MySQL

    • SSMA is a tool provided by Microsoft to help users migrate MySQL databases to SQL Server. This tool helps in converting MySQL database objects, including tables, views, triggers, and stored procedures, to equivalent SQL Server objects.
  • Visual Studio Code Extensions

    • Microsoft provides extensions for Visual Studio Code (VS Code) that allow developers to connect to and manage MySQL databases directly from the editor. These extensions provide features like query execution, database exploration and code snippets.
  • Power BI Integration

    • Microsoft Power Bi can connect to MySQL databases, allowing users to create rich data visualizations and perform business analytics on MySQL data.

Docker Compose Example

networks:
frontend:
external: true
backend:
external: true
services:
db:
container_name: sqlserver
environment:
ACCEPT_EULA: "Y"
MSSQL_SA_PASSWORD: # username is sa with this password to log into the Database.
MSSQL_PID: "Developer" # Developer or Express. Standard and Enterprise require MSSQL_PID which is the product / licence key.
image: mcr.microsoft.com/mssql/server:2022-latest
restart: unless-stopped
volumes:
- ./data/data:/var/opt/mssql/data
- ./data/log:/var/opt/mssql/log
- ./data/secrets:/var/opt/mssql/secrets
ports:
- "1433:1433"

Start MySQL

Now the docker compose file above has had the relevant configuration options set such as SA_PASSWORD, MySQL can now be started using the following command from within folder location where the docker compose file for MySQL has been stored.

docker compose up -d

Key Components of Docker Compose Configuration Explained

  • Image - Specifies the MySQL server image and tag
  • Ports - Exposes MySQL on specified port
  • Volumes - For media files and custom templates
  • Environment - Used for ACCEPT_EULA, MSSQL_SA_PASSWORD and MSSQL_PID which are all required in order for the docker container to start.
  • Labels - Used by Traefik to provide external access to the service, once the service all its dependancies have been started are "healthy" and Accessible, Public Service Name and what provider to use to check and obtain for an SSL Certificate