Created
March 10, 2017 21:10
-
-
Save andreabalducci/742f6b9e58ab2b2f876a92d0c376034c to your computer and use it in GitHub Desktop.
MongoDB :: Drop all databases
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
var admin = db.getSiblingDB('admin'); | |
var dbs = db.adminCommand( { listDatabases: 1 } ); | |
dbs.databases.forEach(function(db){ | |
if(db.name !== 'admin' && db.name !== 'local'){ | |
admin.getSiblingDB(db.name).dropDatabase(); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment