Last active
October 18, 2019 22:03
-
-
Save alkampfergit/f9fe4f38c85e04f899fe4e4c20f6979a to your computer and use it in GitHub Desktop.
Drop all mongo databases except the admin and local database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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