I recently needed to rename a whole bunch of MySQL databases so I created a script to do it. I hope others find it as useful as I do.
The script should be called as follows...
The script performs the following steps...
- Create the new database
- Copy the structure and data
- Transfer all privileges
- Flush the privileges
- Drop the old database (will ask for confirmation)
Note that the script will effectively knock out any app/website that uses it until the database they point to is modified accordingly. Enjoy.