How do you rename a MongoDB database?
Asked 07 September, 2021
Viewed 438 times
  • 60
Votes

There's a typo in my MongoDB database name and I'm looking to rename the database.

I can copy and delete like so...

db.copyDatabase('old_name', 'new_name');
use old_name
db.dropDatabase();

Is there a command to rename a database?

10 Answer