Backup:
mysqldump -u username -p [-h hostname] [database_name] > dumpfilename.sql

Import
mysql -u username -p [-h hostname] [database_name] < path/to/dumpfilename.sql

 

NOTE: One could also type down password in advance -p[password] , but this option is insecure since password will then be visible in shell command history.