Run MySQL using Docker Compose
To run MySQL using Docker Compose
Run MySQL using Docker Compose
To run MySQL using Docker Compose, you need to create a docker-compose.yml file with the following content:
1 | version: '3.1' |
Then run the following command in the same directory as the docker-compose.yml file:
1 | docker-compose up -d |
You can now use adminer to connect to the MySQL server by visiting http://localhost:8000.
lower-case-table-names=1 is used to make table names case-insensitive. This is useful when you are running MySQL on a case-insensitive file system, such as Windows or macOS. see https://dev.mysql.com/doc/refman/8.3/en/identifier-case-sensitivity.html for more information.
You can use a sample table to test the MySQL server. Here is an example of a user table:
1 | CREATE TABLE `user` ( |
Volume
To add a volume to the MySQL container, you can add the following lines to the docker-compose.yml file:
1 | volumes: |
volume ./data will be mounted to /var/lib/mysql in the container. This is useful when you want to persist the data even after the container is removed.