Skip to content

Instantly share code, notes, and snippets.

@simonqian
Created August 21, 2016 14:11
Show Gist options
  • Save simonqian/156757ec4a1e9b61353c7d2f49c98595 to your computer and use it in GitHub Desktop.
Save simonqian/156757ec4a1e9b61353c7d2f49c98595 to your computer and use it in GitHub Desktop.
1. 备份数据库并压缩
mysqldump -h -u -p database | gzip > backupfile.sql.gz
2. 解压并还原数据库
gunzip < backupfile.sql.gz | mysql -uroot -ppassw database
真实例子(带参数)
mysqldump --complete-insert --no-create-info --skip-triggers --ignore-table=cellar.schema_migrations --ignore-table=cellar.regions -uroot -p cellar | gzip > backupfile.sql.gz
gunzip < backupfile.sql.gz | mysql -ucellar -p cellar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment