[Windows] Back up & restore MySQL data from Docker container

Jangwook Kim
Mar 17, 2020
Docker & MySQL

This post will help you to save your time.

Back Up

C:\docker\directory> docker psC:\docker\directory> docker exec container-id /usr/bin/mysqldump -u username database-name > dump.sql

Restore

C:\docker\directory> docker psC:\docker\directory> docker exec -i container-id /usr/bin/mysql -u username database-name < dump.sql

If you want to use docker-compose command…

# To back backup
C:\docker\directory> docker-compose exec -T container-name /usr/bin/mysqldump -u username database-name > dump.sql
# to rollback
C:\docker\directory> docker-compose exec -T container-name /usr/bin/mysql -u username database-name < dump.sql

--

--

Jangwook Kim
Jangwook Kim

Written by Jangwook Kim

Korean, live in Japan. The programmer. I love to learn something new things. I’m publishing my toy projects using GitHub. Visit https://www.jangwook.net.

No responses yet

What are your thoughts?