How to rename a MongoDB database

434585 pts.
Tags:
Database
MongoDB
I just realized there's a typo in my MongoDB database name and I need to change the name ASAP. I've tried to copy and delete it like this:
db.copyDatabase('old_name', 'new_name');
use old_name
db.dropDatabase();
Would there be a command to rename it?

Answer Wiki

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

Hi

You
will easily rename it with the help of given command:

db.copyDatabase(“db_to_rename”,”db_renamed”,”localhost”)

use db_to_rename

db.dropDatabase();

For more info see this: http://docs.mongodb.org/manual/tutorial/backup-with-mongodump/

Discuss This Question:  

 
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.

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.

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

Following

Share this item with your network: