Back up And Restore MySQL Database with Compress
Back up MySQL Database with Compress:
If your mysql database is very big, you might want to compress the output of mysqldump. You can use the mysql backup command below and pipe the output to gzip, then you will get the output as gzip file.
$ mysqldump -u [uname] -p[pass] [dbname] | gzip -9 > [backupfile.sql.gz]
If you want to extract the .gz file, use the command below:
$ gunzip [backupfile.sql.gz]
Restore MySQL Database
To re-create the database ,Create an appropriately named database on the target machine and Load the file using the mysql command:
$ mysql -u [uname] -p[pass] [db_to_restore] < [backupfile.sql]
To restore compressed backup files you can do the following:
gunzip < [backupfile.sql.gz] | mysql -u [uname] -p[pass] [dbname]
