Skip to content

Instantly share code, notes, and snippets.

@Alcar32
Created May 15, 2013 23:19
Show Gist options
  • Save Alcar32/5588204 to your computer and use it in GitHub Desktop.
Save Alcar32/5588204 to your computer and use it in GitHub Desktop.
How to back up and restore a MySQL database
# Back up from the command line (using mysqldump)
mysqldump --opt -u [uname] -p[pass] [dbname] > [backupfile.sql]
# Back up the MySQL database
mysqldump -u [uname] -p[pass] [dbname] | gzip -9 > [backupfile.sql.gz]
# Restoring the MySQL database
mysql -u [uname] -p[pass] [db_to_restore] < [backupfile.sql]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment