Recently, I worked on a project where the database needed to be renamed. I found this script that worked perfectly.
mysqldump -u username -p -v olddatabase > olddbdump.sql mysqladmin -u username -p create newdatabase mysql -u username -p newdatabase < olddbdump.sql
Source: StackOverflow