Import / Export MySQL database via Terminal
To export a mysql database you should use the following command. You can get the name of the database by login into mysql and using the command "show databases"
mysqldump -u YourUser -p YourDatabaseName > output.sql
you will be prompted with a password and after successful authentication the SQL file will be created at the folder from which the execution is done.
Importing database to MySQL via command line
To import an SQL file to database via command line first create a blank database. Fill in the new database name to the syntax given below. Not that the database should be first created and should be blank for the process to work.
mysql -u <username> -p <databasename> < <outputfilename.sql>
While doing this you will be prompted with a password on entry the file will start importing to the database name you have given. After the command execution you can see your data in the new database.