Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rename/Create Database from Existing Database

Status
Not open for further replies.

chz013

Programmer
Jan 5, 2003
73
US
Hi
1- Is there a command to rename an existing database ?
2- If not, how does one create a new database from an existing database ?
could you show me the steps?

Any help is appreciated.
Thanks
 
To my knowledge, there is no MySQL query which will rename a database.

Since with MySQL a database maps to a directory on the filesystem, one shortcut workaround is to create a new empty database, then copy the files from the old database's directory into the new database's directory.

Here's the gotchas:
1. I strongly recommend that you have MySQL shut down for the copy operation.
2. You need to make sure that the permissions on the copied files are correct. You haven't specified your OS, but on Linux the files must be owned by the user and group as which MySQL runs, with permissions 660.

Want the best answers? Ask the best questions: TANSTAAFL!
 
sleipnir214
Thanks for the response.
could you elaborate more with details on the gotchas ?


Also, how do u use mysqlhotcopy ?
 
Not much to say.

MySQL may react better if you create the new database, then shut MySQL down, then copy the old database table files to the new database directory.

And if the permissions aren't right on the files, MySQL will likely barf.

Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top