Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Drop all mongo databases except the admin and local database
var dbs = db.getMongo().getDBNames()
for(var i in dbs){
db = db.getMongo().getDB( dbs[i] );
if (db.getName() !== 'admin' && db.getName() !== 'local')
{
print( "dropping db " + db.getName() );
db.dropDatabase();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.