I would like to know if there\'re a command to drop every databases from my MongoDB?
I know if I want to drop only one datatable, I just need to type the name of the dat
Save this to drop_all_dbs.js:
var databases = db.getMongo().getDBNames()
for(var i in databases){
db = db.getMongo().getDB( databases[i] );
if(db.getName() == "admin" || db.getName() == "local"){
print("skipping db " + db.getName())
continue
}
print( "dropping db " + db.getName() );
db.dropDatabase();
}
Now you can execute:
mongo drop_all_dbs.js
and all databases (except for admin and local) will be dropped.
This answer is a copy of ALoR's one, just fix drop of system dbs