Export:


mysqldump -u <em>username</em> -p <em>database_name</em> > <em>dump.sql</em>

Import:


mysql -u <em>username</em> -p <em>database_name</em> < <em>dump.sql</em>

Live export/duplication (note you may need to enter the password on the line for the mysql command):


mysql -uuser -ppassword -e 'DROP DATABASE test_db;'
mysql -uuser -ppassword -e 'CREATE DATABASE test_db;'
mysqldump -uuser -ppassword live_db | mysql -uuser -ppassword test_db;