Back
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();
db.copyDatabase('old_name', 'new_name');
use old_name
db.dropDatabase();
Is there a command to rename a database?
For renaming a MongoDB database you can use the following way:-
db.copyDatabase("db_to_rename","db_renamed","localhost") use db_to_rename db.dropDatabase();
db.copyDatabase("db_to_rename","db_renamed","localhost")
use db_to_rename
You could do this:
db.copyDatabase("db_to_rename","db_renamed","localhost")use db_to_renamedb.dropDatabase();
31k questions
32.8k answers
501 comments
693 users