tags:

views:

50

answers:

2

Possible Duplicate:
How do I quickly rename a mysql database (change schema name)?

hi , plz help me to rename the database name in mysql

+2  A: 

You should not use rename database as it will result in data loss http://dev.mysql.com/doc/refman/5.1/en/rename-database.html

Instead use alter database syntax http://dev.mysql.com/doc/refman/5.1/en/alter-database.html

Rajeev
Alter can NOT change the name of the database. It can only upgrade the encoding (if possible).
shamittomar
mysqldump command is ur best bet if you want to do this..
Rajeev
+1  A: 

You can choose any of the following ways to rename a database in MySQL.

If you have access to the directory where MySQL stores its databases. As per default MySQL installations, this is usually in the data directory under the directory where MySQL was installed. Locate the name of required database under the data directory and rename it as desired. Note: You must stop MySQL Server before renaming the database and may restart it after this operation. In this case, you may also grant permissions again on the renamed database. This only works for MyISAM tables. If you have tables with other storage engines than use the method described below.

Another way that seems safest, is to use mysqldump utility to back up the old database. Create a new database with desired name, then restore the dumped database under this database using the mysql utility. Finally, use the DROP DATABASE old_database_name; command to get rid of the old database. This is the safest method.

Faisal Feroz