Jump to content


Photo

Trouble with RENAME DATABASE syntax


  • Please log in to reply
2 replies to this topic

#1 dptr1988

dptr1988
  • Members
  • PipPipPip
  • Advanced Member
  • 372 posts

Posted 22 June 2006 - 07:23 PM

I'm trying to rename on of my databases called 'site_info' to 'dptr1988'. So I'm using this command:
RENAME DATABASE site_info TO dptr1988;
But I get a syntax error saying this:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DATABASE site_info TO dptr1988' at line 1
Is the syntax of my rename command correct?

Thanks
Need more help with your project? One of the thousands of programmers, web designers or artists at <a href="http://www.rentacode...d_6764522">Rent A Coder</a> would be happy to help.

Disclaimer: Free advice is usually worth what you paid for it. ( or at least when it's coming from me! )

#2 Wildbug

Wildbug
  • Members
  • PipPipPip
  • Advanced Member
  • 1,149 posts

Posted 22 June 2006 - 08:10 PM


AfaIk, there's no "RENAME DATABASE" command in MySQL. You'll have to do it in a multi-step process. Either export the database and use the backup to create a new database with the new name or shutdown MySQL and rename the directory/table files if you have filesystem permissions to do so. Remember, if you have users with privileges on the old db name, you'll have to update those privileges, too.
Twice a day my clock works PERFECTLY!  I can't figure out what's wrong with it.

#3 dptr1988

dptr1988
  • Members
  • PipPipPip
  • Advanced Member
  • 372 posts

Posted 22 June 2006 - 09:19 PM

Thanks for pointing that out to me. I was very dumb!! The manual said "RENAME TABLE" and somehow my brain saw "RENAME DATABASE". Thanks for helping me!
Need more help with your project? One of the thousands of programmers, web designers or artists at <a href="http://www.rentacode...d_6764522">Rent A Coder</a> would be happy to help.

Disclaimer: Free advice is usually worth what you paid for it. ( or at least when it's coming from me! )




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users