I have a authenticated user with all required privileges to drop a database. I want to drop the database from the shell and tried following command
mongo -uuser -ppass newdb --eval "db.dropDatabase();"
I got following:-
MongoDB shell version: 2.4.9
connecting to: newdb
[object Object]
That's it I got no errors and no results. The database still exists with all values.
Your command should work
mongo -uuser -ppass newdb --eval "db.dropDatabase();"
If you access to mongo after that with
mongo -uuser -ppass newdb
The database is created again but empty, so when you said:
The database still exists with all values.
Are you sure that has all collections inside ?
To check if has been deleted you can do:
mongo -uuser -ppass
> show dbs
The "newdb" shouldn't appear.
I've tested it with Mongo 2.4.2.
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