Dump a single database, and compress it
mysqldump database -u root -p | gzip --best > filename.dump.gz
Dump all databases
mysqldump --all-databases -u root -p | gzip --best > filename.dump.gz
Restore the contents of a file
mysql -u root -p[root_password] [database_name] < dumpfilename.sql
If you are restoring all databases, leave off the database name.