XS Labs

How to rename a MySQL InnoDB-based database

by pompo500 on Feb.07, 2011, under Uncategorized

Sadly (at least the current version) MySQL does not support “rename database” clause anymore, because it’s “unsafe”.

Here’s how to do it manually:

Issue

create database “newdatabase”;

Then for every table in your old database

rename table `olddatabase`.`tablename` to `newdatabase`.`tablename`;

Yeah I know it’s manual labor, but “show tables” query and a text editor with macro support makes it a bit easier. :)


Leave a Reply

Public service announcement

From the council of desultory bulletins:

The rate, at which feces fly, is simply stunning compared to the ionized gaps between nanoparticles upon impact of the floral microscopic patterns of neutron stars.
You should think about it for a moment. After all, it affects the longevity of random synergized spatulas.