The simplest approach is to take a sql dump of a database;
and manually edit the line;
CREATE DATABASE *name* IF NOT EXISTS
then restore the mysqldump file with;
mysql -u [user] -p [database] < backupfile.sql # Restore </PHP>