How to use gzip or gunzip with mysqldump/mysql to import/export

The syntax is fairly easy and it is a common practice to use gzip specially when you transfer your backup files over two or more different servers so here is the syntax.

Exporting:

mysqldump -u user -p database | gzip > database.sql.gz

Importing:

gunzip < database.sql.gz | mysql -u user -p database

More from mysqldump + MySQL + Utility