What's the easiest way to do this from my bash prompt?
Then you can use “show dbs” command for checking the list of Databases. Then select the database you want to delete using command “use databasename“. Then execute db. dropDatabase() command to drop an existing database.
MongoDB db. dropDatabase() command is used to drop a existing database.
To delete a MongoDB Collection, use db. collection. drop() command.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With