SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Apr 2002
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to change a database's name in MySQL?

    I have really no idea.
    Please tell me.

  2. #2
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you can control MySQL, the easiest way would be to shut down MySQL, and rename the database's directory. however, i think this might mess up permissions if they're not the same on all databases.

    the other way that i know of is to create the new database, dump the old one, import it into the new one, and drop the old one. say your old DB is `db1' and you want to rename it to `db2'. create `db2' and you can copy everything from `db1' with this one command:

    Code:
    mysqldump --opt -udb1_user -pdb1_pass db1 | mysql -udb2_user -pdb2_pass db2
    hopefully that'll work. then you can `DROP DATABASE db1'.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •