swapnilsarwe
5/25/2018 - 1:21 PM

mysql: backing up & restoring db

mysql: backing up & restoring db

mysqldump -u mysqluser -p mysqlpassword mysqldatabase > db_backup.sql # simple backup
mysqldump -u mysqluser -p mysqlpassword mysqldatabase | gzip > db_backup.sql.gz # gzipped backup

cat db_backup.sql | mysql -u mysqluser -p mysqlpassword mysqldatabase # simple restore
gunzip < db_backup.sql.gz | mysql -u mysqluser -p mysqlpassword mysqldatabase # restoring gzipped sql file