Skip to content

Instantly share code, notes, and snippets.

@perrmadiafrrian
Forked from devdrops/example.md
Created March 13, 2020 01:17
Show Gist options
  • Save perrmadiafrrian/4995fc847506d18fa42e811e816f12b2 to your computer and use it in GitHub Desktop.
Save perrmadiafrrian/4995fc847506d18fa42e811e816f12b2 to your computer and use it in GitHub Desktop.
Mysqldump from Docker container

Mysqldump from Docker container

docker exec -i mysql_container mysqldump -uroot -proot --databases database_name --skip-comments > /path/to/my/dump.sql

OBS

  • This will generate a dump.sql file in your host machine. Awesome, eh?
  • Avoid using --compact on your dump. This will make MySQL check your constraints which will cause troubles when reading your file (damm you MySQL). And don't use --force to fix this scenario: recreate your dump without --compact ¯_(ツ)_/¯
  • You can execute the same command for both Docker and Docker Compose scenarios 😉
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment