MySQL: Clone a existing Database on the command line

logo-mysql-110x57

Today i had to create a clone of a production database to run some tests to another than the production database, so here are two ways to do this very fast and as a one liner on the command line:

1.

mysql -u -p -e "create database " && mysqldump -u -p  | mysql -u -p 

2.

mysqladmin create  -u -p && mysqldump -u -p  | mysql -u -p