Skip to content

Instantly share code, notes, and snippets.

@QinMing
Last active October 9, 2018 08:26
Show Gist options
  • Save QinMing/3512c5164667a5014809ebd8fec14aad to your computer and use it in GitHub Desktop.
Save QinMing/3512c5164667a5014809ebd8fec14aad to your computer and use it in GitHub Desktop.
MySQL utils
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