Created
October 11, 2019 07:03
-
-
Save munkhorgil/40d48318190bd3daeba12c19ad659485 to your computer and use it in GitHub Desktop.
Remove all mongo dbs except local, admin
This file contains 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
// Remove all databases, except local, admin | |
// on command line: mongo filename.js | |
const 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