How can I create and import a database using command line ?

create backup

sudo mysqldump -u root -p dbname > backup.sql

I believe the format is:

mysql -u username -p database_name < /path/to/file.sql

From within mysql:

mysql> use db_name;
mysql> source backup-file.sql;