MySQL Database Backup In GZ Format On Linux 7

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.

Check Out: How To Install Active Directory Server On Windows 2012/2016 R2

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.

Check Out: Command To Restore And Backup Of MySQL Server

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.

show databases;

mysql backup linux

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

mysql import complete dump

Check Out: How To Check Users In Mysql Database Server In Linux

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 

Check Out: How To Install Youtube-dl To Download Videos on Ubuntu 20.04/19.10

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

Share on:

I'm the founder of Curious Viral. I hope this blog will provide you complete information about Linux Technology & I would like to share my technical knowledge with you which I have learned during this period.

Other Posts You May Like...

Leave a comment