从bash提示符中最简单的方法是什么?


当前回答

db将显示当前的数据库名称 类型:db.dropDatabase ();

1-使用'use'关键字选择要删除的数据库。

2-然后输入db.dropDatabase();

其他回答

其他方式:

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

启动MongoDB

数据库删除命令为:

1. 首先选择要删除的数据库

use < database name >

2. 然后用这个。。

db.dropDatabase()

在终端执行:

mongo // To go to shell

show databases // To show all existing databases.

use <DATA_BASE> // To switch to the wanted database.

db.dropDatabase() // To remove the current database.

打开终端,输入:

mongo 

下面的命令应该显示列出的数据库:

show dbs 

/* the <dbname> is the database you'd like to drop */
use <dbname> 

/* the below command will delete the database */
db.dropDatabase()  

终端输出如下:

{
  "dropped": "<dbname>",
  "ok": 1
}

下面是一些使用mongodb完全删除操作的mongo shell

删除集合中的特定文档。删除({name:"stack"})

删除集合中的所有文档:db.mycollection.remove()

删除集合:db.mycollection.drop()

删除数据库。 首先使用mydb命令进入该数据库,然后

db.dropDatabase()

mydb——eval "db.dropDatabase() "