This script cycles through each table in the database and renames it. The PassWord is included in the script to save you having to enter it for each cycle.

3. If you have a very small database, you can move the tables manually. This can be less intimidating than running a script, but time-consuming. Start by logging into the MySQL shell:

mysql –u UserName –p

Use the RENAME TABLE command to rename a table:

RENAME TABLE ExistingDatabase.Table1 TO NewDatabase.Table1;

Replace Table1 with the name of a table in the ExistingDatabase. If you have more than one table in this database, you’ll need to repeat this action for each table.

Conclusion

With this guide, you should now know how to rename a MySQL database.

If you’re working with an older version of MySQL (5.1.7 and older), you may have the ability to use the RENAME DATABASE command. It is strongly recommended that you update your database for security and stability, and use the renaming methods in this guide.