MySQL Database Backup In gz Format On Linux 7
I have created three databases in MySQL server just to show you how to make MySQL database backup in GZ format. Why in GZ format? Because it reduces the actual size of the database by 1/10 size. Suppose if you have a database with 10 GB size, So it will reduce this size to approx 1 GB. We can import or take a complete MySQL database backup dump using GZ format in Linux.
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 the database available on the MySQL server.
Check the size of the 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 bunzip2 filename.sql.bz2
You’re done mysql import complete dump