How to export/import a MySQL database via SSH

1. Exporting a MySQL database

mysqldump -p -u username database_name > file.sql
mysqldump -p -u username db_name tbl_name >file.sql

2. Import A MySQL Database
The file must be in .sql format. It can not be compressed in a .zip or .tar.gz file.

mysql -p -u username database_name < file.sql