Run the following command to dump a database:
# mysqldump database_name > Database_name.sql
For example, you want to dump a database called “mydb”.
# mysqldump mydb > mydb.sql
Note: Proper sync for the command would be and maybe required:
# mysql -u username -p -h localhost database_name < database_back.sql
After you have the database backed up, simply import the contents to your destination database.
# mysql new_database_name < Database_name.sql
Here we are going to use the new destination database known as “newmydb”.
# mysql newmydb < mydb.sql
You should see two databases that are similar, but with different names, after the transfer is completed.