You’ve got your MySQL database up and running. Everything is going smoothly. But then for some reason you need to change your MySQL schema name. You just go in to the schema and click the rename button, right?
WRONG.
MySQL doesn’t let you change the schema name quite that easily. You have to jump through a few hoops. If you’ve got a ton of data or a lot of tables, either one is going to be a royal pain. Still, this is just the way things go sometimes.
Here are your two options.
Export and Re-Import the Schema
This is probably a good idea anyway, if you’re doing some serious database work. This ensures you have a full backup of all the data in the system. Export everything out into raw files. Create a new schema. Import the data into that new schema.
MAKE SURE YOU HAVE ALL THE ROWS. Sometimes things go wrong. Double check.
Then delete your old schema with the old name.
Or you can go with:
Rename Each Table Manually
Yes, if you have a lot of tables this can be a royal pain. But if you aren’t able to export and reimport the tables for some reason, this is another alternative. Make your new schema. Then edit each table one by one and change it to belong to the new schema. It might take a while, but nothing is “moving” in any real sense. So it should be fairly quick and not take any disk space or such in the process.
Let me know if you have any other ideas!
Leave a Reply