At 11:16 -0500 10/7/04, gerald_clark wrote:
Carolina wrote:
using mysql version 4.0.13
- **total newbie here**... something as simple as renaming a
database...i've not found anything relating to that on the mysql site
or anywhere else. what i have found is that in order to do this, i'd
have to shutdown and restart the mysql database in order to do
something as simple as this. is there another way? as mysql user
'root' i've tried:
mysql> rename database old_db to new_db
thnx,
cheers!
-a
You may think this is simple, but you have to make sure all users
are out of the database, and all records are flushed
before it could be renamed. It is much safer to shutdown the server
and rename the directory.
It's simple conceptually, but complex to actually implment. In addition
to the issues gerald mentions, remember that if you have InnoDB tables,
they aren't actually stored in the database directory unless you're
using individual tablespaces -- and even then, there is an entry for
them in the InnoDB data dictionary that is stored in the shared tablespace.
And those entries include the database name. If you rename the database
directory, those entries become invalid. Also, if you have foreign key
relationship, there are similar difficulties.
Might be better to create a new database and then RENAME TABLE each table
from the original database into the new database. Then drop the original
database.
The strategy of shutting down the server, renaming the database directory,
and restartingg the server does work fine _if_ your database contains only
MyISAM (or ISAM) tables, though.
--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]