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\', \
I tried doing.
db.copyDatabase('DB_toBeRenamed','Db_newName','host')
and came to know that it has been Deprecated by the mongo community although it created the backup or renamed DB.
WARNING: db.copyDatabase is deprecated. See http://dochub.mongodb.org/core/copydb-clone-deprecation
{
"note" : "Support for the copydb command has been deprecated. See
http://dochub.mongodb.org/core/copydb-clone-deprecation",
"ok" : 1
}
So not convinced with the above approach I had to take Dump of local using below command
mongodump --host --db DB_TobeRenamed --out E://FileName/
connected to Db.
use DB_TobeRenamed
then
db.dropDatabase()
then restored the DB with command.
mongorestore -host hostName -d Db_NewName E://FileName/