Export and Import MySQL Databases in Terminal
Export database
Export your database to create a backup using the following command:
$ mysqldump --opt --hex-blob [-h host] -u [user] -p [database] > [database].sql
Compress with gzip
You can also compress your database on-the-fly with gzip:
mysqldump --opt --hex-blob [-h host] -u [user] -p [database] | gzip -c > [database].sql.gz
Show progress
To show progress, you can use pv: