Skip to content

Instantly share code, notes, and snippets.

@gustavobgama
Created December 3, 2013 20:17
Show Gist options
  • Save gustavobgama/7776791 to your computer and use it in GitHub Desktop.
Save gustavobgama/7776791 to your computer and use it in GitHub Desktop.
Commands to export/import/transport mysql database dumps
# Reference: http://webcheatsheet.com/sql/mysql_backup_restore.php
# import without compression
mysql --host=host --user=user --password=password database < path_to_file.sql
# import with compression
gunzip < path_to_file.sql.gz | mysql --host=host --user=user --password=password database
# export wihtout compression
mysqldump --host=host --user=user --password=password database table --where="condition" > path_to_file.sql
# export with compression
mysqldump --host=host --user=user --password=password database table --where="condition" | gzip -9 > path_to_file.sql.gz
# dump between servers
mysqldump --host=host --user=user --password=password database | ssh user@server "mysql --user=user --password=password database"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment