This shell command will duplicate an existing database:
# mysqladmin create DB_name -u DB_user --password=DB_pass && \ mysqldump -u DB_user --password=DB_pass DB_name | mysql -u DB_user --password=DB_pass -h DB_host DB_name
Replace DB_* with your MySQL settings. Where could this be useful besides making a mirror backup of a database?
I am thinking of a Rails app running on a production server. You would like to test major code upgrades or database migrations on the production hardware before you mess with your business data, but don't have money to clone your production hardware.
This approach would simply duplicate the production database and deploy the app on the same server, running on a high port number. Needs a Capistrano recipe to be done!