MySQL Database Backup In gz Format On Linux 7
I have created three database in MySQL server just to show you how to take MySQL database backup in GZ format. Why in GZ format? Because it reduces the actual size of database by 1/10 size. Suppose if you have database with 10 GB size, So it will reduce this size to approx 1 GB.
Check Out : Command To Restore And Backup Of MySQL Server
This can be done using the script too and you can restore the database anytime you want and will be easy to copy the large database.
Create database testing;
You can check database available in MySQL server.
Check the size of database by running below command
du -sh /var/lib/mysql/testing/
Now take the backup in gz format using the following commands
mysqldump -u root -p testing | gzip > testing.sql.gz
you can restore the database from testting.sql.gz to your running MySQL server but you will have to extract the gz format.
gunzip -d testing.sql.gz
you can also try the below command.
gzip < testing.sql.gz | mysql -u root -p[pass] dbname
In the same way, you can also take backup in bz2 format and extract using the same way.
mysqldump -u root -p testing | gzip > testing.sql.bz2