Submitted by andreychek on Fri, 11/11/2011 - 09:50
When renaming a Virtual Server, the databases within it aren't renamed.
That may be what some folks want, but others are interested in renaming the database to match.
In Server Configuration -> Change domain name, would it be possible to add an option to that list, asking if they would like to rename the database(s)?
Status:
Active
Comments
Submitted by JamieCameron on Fri, 11/11/2011 - 12:16 Comment #1
This is actually pretty tricky, for two reasons :
MySQL doesn't have any way to rename a database. It would have to be backed up to a file, deleted, re-created and restored.
Any scripts that are using the old DB name will be broken by a rename.
Submitted by ADobkin on Wed, 05/22/2013 - 05:26 Comment #2
Renaming a live MySQL database is easy if it does not contain any views or stored procedures. The steps are:
mysql -e "CREATE DATABASE \`new_database\`;"
for table in `mysql -B -N -e "SHOW TABLES;" old_database`
do
mysql -e "RENAME TABLE \`old_database\`.\`$table\` to \`new_database\`.\`$table\`"
done
# Drop the old database once the new one is tested / confirmed working
#mysql -e "DROP DATABASE \`old_database\`;"
Submitted by rsecor on Fri, 02/14/2020 - 15:37 Comment #3
I just ran into this. It failed to change the database name accordingly when I changed a virtual server.
In my case, it shows that it is missing some information when changing the name.
As an example, it shows: 'example.com'localhost' to 'example.org'localhost'
It should show: 'example.com'@'localhost' to 'example.org'@'localhost'
This leads me to believe that a script is not using the correct information.
Submitted by JamieCameron on Fri, 02/14/2020 - 23:01 Comment #4
For now, we've decided not to implement database renames due to the complexity and potential script breakage they can cause.
Submitted by rsecor on Sat, 02/15/2020 - 07:46 Comment #5
In that case can you just disable the attempt to rename them so we don’t get messages?
Maybe just a informational message about the database not being renamed?
Submitted by JamieCameron on Sat, 02/15/2020 - 16:48 Comment #6
No rename should be happening though. What's the exact error message that you're getting?