Skip to content

Instantly share code, notes, and snippets.

@nicoavila
Last active October 14, 2024 22:17
Show Gist options
  • Save nicoavila/fd4725428bd2991bb9237b3c7d770e76 to your computer and use it in GitHub Desktop.
Save nicoavila/fd4725428bd2991bb9237b3c7d770e76 to your computer and use it in GitHub Desktop.
Docker Compose file for a MySQL 5.7 container
version: '3.3'
services:
database:
image: mysql:5.7
container_name: mysql
restart: always
environment:
MYSQL_DATABASE: 'db'
MYSQL_USER: 'user'
MYSQL_PASSWORD: 'password'
MYSQL_ROOT_PASSWORD: 'password'
ports:
- '3306:3306'
expose:
- '3306'
volumes:
- './.mysql-data/db:/var/lib/mysql'
@jjromannet
Copy link

I think this config missing MYSQL_ROOT_HOST: '%' to allow root connecting from any address. Here is mine example: https://gist.github.com/jjromannet/9a5ee7e480801576b68af1ed5fd8e979

@j4viermora
Copy link

I want create root, is necesary add MYSQL_ROOT_USER: 'root' ??

@carlitosfigueredo
Copy link

Thanks!

@guidefari
Copy link

this just worked perfectly for me, thanks for sharing.

@charl
Copy link

charl commented Oct 5, 2023

Added this to build on macOS:

platform: linux/x86_64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment