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
 
 
posted @ 2014-11-14 16:22  seasonzone  阅读(335)  评论(0编辑  收藏  举报