Last active
October 9, 2018 08:26
-
-
Save QinMing/3512c5164667a5014809ebd8fec14aad to your computer and use it in GitHub Desktop.
MySQL utils
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
backup: | |
docker stop mysql1 || true | |
docker run --rm --volumes-from mysql1 -v $(BACK_DIR):/backup ubuntu tar cvf /backup/sql_volume.tar /var/lib/mysql | |
docker start mysql1 | |
restore: | |
docker stop mysql1 | |
docker run --rm --volumes-from mysql1 -v $(BACK_DIR):/backup ubuntu bash -c "rm -rf /var/lib/mysql/* && cd / && tar xvf /backup/sql_volume.tar" | |
docker start mysql1 | |
load: | |
docker exec -i mysql1 mysql -uroot $(DATABASE_NAME) < mysqldump | |
start: | |
docker run -d --restart=always --name=mysql1 -p=3306:3306 -e=MYSQL_ALLOW_EMPTY_PASSWORD=yes mysql:5.7.21 --max-allowed-packet=1073741820 --wait-timeout=2147483 --interactive-timeout=2147483 --default-time-zone='+00:00' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment