Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , ,

Sponsored Links



Rename mysql database

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 11-11-2009
Member
 
Join Date: Oct 2009
Posts: 10
Rename mysql database

Does any one know the command to rename mysql database. I have created a database with name database1 and now i want to convert or change that name in to database2. What are syntax use in mysql to change the database name. I have tried to change that from command
Code:
rename database database TO database1
and it says its invalid syntax by database..
Reply With Quote
  #2  
Old 11-11-2009
Member
 
Join Date: Jan 2009
Posts: 199
Re: Rename mysql database

If you're renaming the DB by command line, you'll want to grant user permissions to the new DB and delete permissions granted for the old DB.you can just rename the folders that store the databases while the server is. But that doesn't work when you have at least one InnoDB table, because renaming folders wrecks the tablespace. But that does not work when you have at least one InnoDB tableYou either run an SQL query to do this or do it with phpMyAdmin if you don't want to bother remembering the SQL to do so.
Reply With Quote
  #3  
Old 11-11-2009
Zecho's Avatar
Member
 
Join Date: May 2008
Posts: 2,267
Re: Rename mysql database

Use the following code to rename mysql database
Code:
mv databse databse1

cd database/

mv databse.frm database1.frm

mv databse.MYD database1.MYD

mv databse.MYI databse1.MYI

Restart MySQL

/etc/init.d/mysql start
Reply With Quote
  #4  
Old 11-11-2009
Member
 
Join Date: Dec 2008
Posts: 177
Re: Rename mysql database

MySQL does not support a database rename command. If MySQL has no command for renaming a database then the safest way is to use mysqldump to back up the old database, then restore the dump. Using mysqldump, dump the database. The mysqldump client can be used to dump a database or a collection of databases for backup or for transferring the data to another SQL server.
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Rename mysql database"
Thread Thread Starter Forum Replies Last Post
Need MySQL database directory Osman84 Software Development 4 27-02-2010 05:18 AM
Mysql Error : Can't connect to local mysql server through socket ' var lib mysql mysql.sock' 2 roshan45 Software Development 3 07-11-2009 09:36 PM
How to add mysql database to localhost? gazwsx Software Development 3 01-07-2009 08:07 PM
Restoring MySQL database Sean J Software Development 5 18-02-2009 01:46 PM
How to Connect MySQL database from PHP Booth Software Development 3 21-01-2009 09:12 PM


All times are GMT +5.5. The time now is 07:47 AM.