To dump a mysql database use the mysqldump command and pipe it to gzip on the fly so the resulting backup file is compressed with this command:
mysqldump -u[uname] -p [dbname] | gzip – > backupfilename.dmp.gz
To restore this on another machine you need to create the databse using mysqladmin
mysqladmin -u[uname] -p create schemaname
Then load the data with
gunzip < [backupfile.sql.gz] | mysql -u [uname] -p[pass] [dbname]