Skip to content

Instantly share code, notes, and snippets.

@davidromani
Last active October 19, 2016 14:12
Show Gist options
  • Save davidromani/2651376 to your computer and use it in GitHub Desktop.
Save davidromani/2651376 to your computer and use it in GitHub Desktop.
Backup and Restore MySQL database
### MySQL v5.0
mysqldump -h <host> -u <username> -p <password> <database_name> > backup_db_file.sql
mysql -u <username> -p <password> <database_name> < <backup_db_file.sql>
### MySQL v5.5
mysqldump -h <host> -u <username> -p <database_name> > backup_db_file.sql
mysql --user=<username> --password=<pass> -A <database_name> < <backup_db_file.sql>
### MySQL ROOT migrations with secure copy remote
mysqldump -u root -p<pass> -B --opt --events --routines --triggers <database_name> | ssh <user>@<remote_host> 'cat - | mysql -u root -p<pass>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment