Last active
September 10, 2022 14:39
-
-
Save joinemm/14d42dc7bf0187946827d9c216269b88 to your computer and use it in GitHub Desktop.
Backup and restore data from a running mysql docker container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. start the db container and map it to local port 3306 | |
# 2. dump it (remove --no-create-info to also migrate schema) | |
$ mysqldump --port 3306 -h 0.0.0.0 -prootpw --no-create-info database > mydb.sql | |
# 3. move to another host | |
$ scp source:~/mydb.sql dest:~/ | |
# 4. start db on destination | |
# 5. create schema if not created automatically | |
# 6. restore data | |
$ mysql --port 3306 -h 0.0.0.0 -prootpw database < mydb.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment