To export a MySQL database, you need to use the mysqldump command. Here is the full command for exporting your database:
mysqldump -uUSERNAME -p'password' DATABASE > backup.sql
To import a MySQL database, you need to use the mysql command. Here is the full command:
mysql -uUSERNAME -p'password' DATABASE < backup.sql
If you need to dump and compress using .gz
mysqldump -uUSERNAME -p'password' DATABASE | gzip > dumpfilename.sql.gz