How to rename a MySQL database quickly

351965 pts.
Tags:
Database
MySQL
MySQL Database
How would I be able to rename a MySQL database quickly? Most of the time, I usually just dump the database and re-import it with a new name. But since this is a huge database, this isn't possible. Can anyone help me here?

Answer Wiki

Thanks. We'll let you know when a new response is added.

For InnoDB, the following seems to work: create the new empty database, then rename each table in turn into the new database:

RENAME TABLE old_db.table TO new_db.table;

You will need to adjust the permissions after that.

And also have a look: http://blog.marceloaltmann.com/how-to-rename-a-database-in-mysql/

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • AshishSingh10
    Hi,

    The following code can be helpful: -

    RENAME {DATABASE | SCHEMA} db_name TO new_db_name;


    Thanks and regards
    Ashish@S
    770 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following