Export a database which is called Test:
mysqldump -u <username> -p Test > Test.sql
The sql file will be generated after you input the password.
Import a database:
1. Create a new database called Test2
2. Import the Test.sql into the Test2
mysql -u root -p Test2 < Test.sql
Reference: How to Back Up and Restore a MySQL Database