How to drop or delete a collection in MongoDB?
问题 What is the best way to drop a collection in MongoDB? I am using the following: db.collection.drop() As described in the manual: db.collection.drop() Removes a collection from the database. The method also removes any indexes associated with the dropped collection. The method provides a wrapper around the drop command. But how can I drop it from the command line? 回答1: So either of these are valid ways to do it: mongo <dbname> --eval 'db.<collection>.drop()' # ^^^^^^^^ ^^^^^^^^^^^^ db.