Mongodb – How to drop a MongoDB database from the command line

mongodb

What's the easiest way to do this from my bash prompt?

Best Answer

Like this:

mongo <dbname> --eval "db.dropDatabase()"

More info on scripting the shell from the command line here: https://docs.mongodb.com/manual/tutorial/write-scripts-for-the-mongo-shell/#scripting