I have a bunch of empty databases showing up in my MongoDB (from time to time, and for an unknown reason) and I'm looking for an easy way to drop all of the empty ones. Here is a piece of the results of the 'show dbs' command, and it's clear which ones are empty and which is not.
rs0:PRIMARY> show dbs
1442036273 (empty)
1442643016 (empty)
1443249599 (empty)
<script>document (empty)
<script>foo< (empty)
CFIDE (empty)
CSCOnm (empty)
CVS (empty)
ConsoleHelp (empty)
ControllerWeb (empty)
DB4Web (empty)
MYDB 0.203GB
HNAP1 (empty)
IDMProv (empty)
MM (empty)
MSWSMTP (empty)
NASApp (empty)
Orion (empty)
OvCgi (empty)
Reporting (empty)
SAPHostControl (empty)
...
Any ideas?
Copyright Notice:Content Author:「BoriS」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/32867307/drop-empty-databases-from-mongodb