Skip to content

Instantly share code, notes, and snippets.

@WebSofter
Last active November 12, 2024 03:13
Show Gist options
  • Save WebSofter/47d4d18e150a290a3fce1afa40ac8b0f to your computer and use it in GitHub Desktop.
Save WebSofter/47d4d18e150a290a3fce1afa40ac8b0f to your computer and use it in GitHub Desktop.
Snippet for MySQL database in docker-compose
APP_TAG=doska
MYSQL_ROOT_PASSWORD=secret
MYSQL_DB=doska
MYSQL_USER=doska
MYSQL_PASSWORD=secret
version: '3.3'
services:
doska_mysql:
image: mariadb
container_name: doska_mysql
volumes:
- ./docker/mysql:/var/lib/mysql
env_file: .env
environment:
MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD
MYSQL_DATABASE: $MYSQL_DB
MYSQL_USER: $MYSQL_USER
MYSQL_PASSWORD: $MYSQL_PASSWORD
#MYSQL_ROOT_HOST: '%' #For external access. Uncommet, if you need
restart: always
ports:
- '3306:3306'
networks:
- doska-network
volumes:
doska_mysql:
driver: local
networks:
doska-network:
driver: bridge
For Connect
Server=doska.kupeyka.com;Database=doska;User ID=root;Password=secret;Trusted_Connection=True;MultipleActiveResultSets=true
For Import dump
docker exec -i some-mysql sh -c 'exec mysql -u<user> -p<password> <database>' < /some/path/on/your/host/all-databases.sql
For export dump
docker exec some-mysql sh -c 'exec mysqldump --all-databases -u<user> -p<password> <database>' > /some/path/on/your/host/all-databases.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment