I used that technique in the past, but had forgotten the exact syntax of the one liners. So let’s say you don’t have enough storage on your partition to have both the SQL dump and the actual data, you can import it or export it directly from the compressed file.
Exporting:
mysqldump -u user -p database | gzip > database.sql.gz
Importing:
gunzip < database.sql.gz | mysql -u user -p database