I do this frequently:
mysqldump -u username -p databasename > dump.sql
To load:
mysql -u username -p targetdatabasename < dump.sql
Switch -p
instructs the database to prompt you to enter the password for the user username
once the command launches.
Your question is probably duplicate though.