Rename a database, how hard can it be…

.. in MySQL?

Just found out renaming database in mysql isn’t as straightforward as it could be, amazing ..

Mysql 5.0.51a ( the version running on the server ) doesn’t allow you to rename a database, after some googling i found the answer. MySQL implemented this feature in 5.1.17. The next paragraph in the MySQL docs made me smile :)

This statement was added in MySQL 5.1.7 but was found to be dangerous and was removed in MySQL 5.1.23. It was intended to enable upgrading pre-5.1 databases to use the encoding implemented in 5.1 for mapping database names to database directory names (see Section 8.2.3, “Mapping of Identifiers to Filenames”). However, use of this statement could result in loss of database contents, which is why it was removed. Do not use RENAME DATABASE in earlier versions in which it is present.

Leave a Reply