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
you can create a javascript loop that do the job and then execute it in the mongoconsole.
var dbs = db.getMongo().getDBNames()
for(var i in dbs){
db = db.getMongo().getDB( dbs[i] );
print( "dropping db " + db.getName() );
db.dropDatabase();
}
save it to dropall.js and then execute:
mongo dropall.js
You can also do this with a simple mongo command:
db.adminCommand("listDatabases").databases.forEach( function (d) {
if (d.name != "local" && d.name != "admin" && d.name != "apiomat" && d.name != "config")
db.getSiblingDB(d.name).dropDatabase();
})