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 tool or with a dump using GZ format in Linux.
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.
You can also use the open-source Percona XtraBackup tool for this. We can also use the SQLYog tool which is a GUI based where you can import and export the backup of the database and much more.
We can take MySQL database backup with a tool or command line on Linux. We can also take it using the script that will automatically backup on the given location.
MySQL Database Backup In gz Format On Linux 7:
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