Skip to content

Instantly share code, notes, and snippets.

@alkampfergit
Last active October 18, 2019 22:03
Show Gist options
  • Save alkampfergit/f9fe4f38c85e04f899fe4e4c20f6979a to your computer and use it in GitHub Desktop.
Save alkampfergit/f9fe4f38c85e04f899fe4e4c20f6979a to your computer and use it in GitHub Desktop.
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