Backup MySQL Database via SSH/Command Line

With mysqldump, you have a handy tool for creating logical backups of your MySQL databases. The result of a mysqldump operation is a SQL file, which can be utilized later to restore one or multiple databases.

Well, Gzip can work in harmony with mysqldump to reduce the output size. It offers 9 compression stages, with 6 being the standard one.

We want to generate a dump and shrink it using gzip (standard compression level). We can accomplish this with the command below:

mysqldump -u username -h localhost -p database_name | gzip > backup_db.sql.gz

Suppose we want to backup the database, but now with a compression level of 8. We can execute it with the command below:

mysqldump -u username -h localhost -p database_name | gzip -8 > backup_db.sql.gz

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Do I use localhost or remotemysqlhost for my mysql connection?

You can view whether your account is using localhost or remotemysql host in your cPanel account....

How can I connect to a MySQL database from Dreamweaver?

To connect to a MySQL database from Dreamweaver follow the below steps:Login to your cPanel...

How do I create a MySQL backup?

There are two ways to back up your MySQL databases. You can use the backup utility in your cPanel...

I would like to dump the Table Structure for my MySQL Database, but none of the data.

The command line option from SSH is: mysql -d -p database_name > file.sql. Where...

How do I create a MySQL database?

To create a MySQL database please follow the steps below:- Login to your control panel at...