Scott Hamm <[EMAIL PROTECTED]> wrote on 07/18/2005 12:01:49 PM: > How do I rename a database? The help online is pretty ambigous. > > -- > Power to people, Linux is here.
I wouldn't say "ambiguous". I would rather say "indirect". Renaming a database is nearly the same thing as moving tables to a new database. you can do that with RENAME TABLE (http://dev.mysql.com/doc/mysql/en/rename-table.html). The only thing to do is to migrate permissions from the old database to the new one (and any table-specific or column-specific permissions, too) by either performing a set of GRANT and REVOKE statements or by updating the `mysql`.`db`, `mysql`.`tables_priv`, and `mysql`.`columns_priv` tables manually and issuing a FLUSH PRIVILEGES statement to put your updates into effect. Normally, the names of databases aren't as nearly as important or mutable as the names of the tables and columns within them. That's why there is no "simpler" method for renaming a database with MySQL. One shortcut, just for MyISAM tables, might be to shut down the server, rename the folder for the database to the new name, then restart the server. This still leaves any permissions pointing to the "old" name and will not work for InnoDB and probably won't work for BDB databases but it could save you the trouble of scripting all of those RENAME TABLE statements. Shawn Green Database Administrator Unimin Corporation - Spruce Pine