How do I drop a MongoDB database, from the command line?

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


> use mydb; 
> db.dropDatabase();


mongo localhost/db <<EOF
db.dropDatabase()
EOF
Results in output like:
mongo localhost/db <<EOF
db.dropDatabase()
EOF
MongoDB shell version: 2.2.2
connecting to: localhost/db
{ "dropped" : "db", "ok" : 1 }    
bye


command for Database drop is :

  1. first select the database which you want to delete

    use < database name >

  2. db.dropDatabase()

echo "db.dropDatabase()" | mongo <database name>


http://stackoverflow.com/questions/8857276/how-do-i-drop-a-mongodb-database-from-the-command-line
 
 
原文地址:https://www.cnblogs.com/seasonzone/p/4097606.html