Last active
December 20, 2019 07:36
-
-
Save qzm/a86aae81b010078129866a94d750e0a1 to your computer and use it in GitHub Desktop.
Docker MySql Backup and Restore
This file contains hidden or 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
# Backup | |
docker exec CONTAINER /usr/bin/mysqldump --set-gtid-purged=OFF -u root --password=root DATABASE > backup.sql | |
# Restore | |
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE |
--set-gtid-purged=OFF
/usr/bin/mysqldump --set-gtid-purged=OFF -u root --password=root DATABASE > backup.sql
/usr/bin/mysql -u root --password=root DATABASE
/usr/bin/mysqldump --host="127.0.0.1" --port=3306 --set-gtid-purged=OFF -u root --password="123456" DATABASE > backup.sql
sudo docker run --rm -it mysql:5.7 /usr/bin/mysqldump --host="127.0.0.1" --port=3306 --set-gtid-purged=OFF -u root -p DATABASE > backup.sql
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sudo docker exec CONTAINER /usr/bin/mysqldump -u root --password= root DATABASE TABLE > TABLE.sql