When you develop with mongo, sometimes you simply need to delete all database quickly because you need to start from scratch. Using shell is really simple, because this gist does exactly what you need.
This snippet is a little bit smarter than deleting everything, because it keeps safe Local and Admin database , and this will preserve users of the database. I always suggest people to develop with authentication enabled, it is a good way to avoid forgetting to secure your production mongo installation and exposing your data at risk.
If you simply delete ALL databases or delete data directory, you will lose users of the database, as well as any information that is stored in admin or local db.
The script is super simple, you can use the getDBNames() function to grab a list of all database names, then you can iterate for each database doing what you want. In this example I simply check the name of the db, and if the db name is different from local or admin, I simply drop it.
The very same script can be used to delete all collection named logs from all databases, or you can simply decide to delete all database with a name that starts with a specific string.
The script is almost the same.