login with root user
1
2
3
$ mongo
>> use admin
>> db.auth("username", "password")
Drop all databases except for internal collections
1
2
3
4
5
6
7
8
9
10
11
db
.getMongo()
.getDBNames()
.filter(n => !['admin','local','config'].includes(n))
.forEach(dname =>
db
.getMongo()
.getDB(dname)
.dropDatabase()
)
;