Mongodb 提供用户名和密码时出现mongorestore警告

Mongodb 提供用户名和密码时出现mongorestore警告,mongodb,Mongodb,我正在使用mongorestore命令行将gzip转储恢复到数据库 在我的MongoDB实例上启用了安全性,因此我需要向命令行提供用户名和密码,以便我有权完成上述恢复 但是为了让MongoDB对用户进行身份验证,还提供了-d选项,让MongoDB知道使用哪个数据库对用户进行身份验证 由于我使用了-d,mongorestore抱怨如下: the --db and --collection args should only be used when restoring from a BSON fil

我正在使用mongorestore命令行将gzip转储恢复到数据库

在我的MongoDB实例上启用了安全性,因此我需要向命令行提供用户名和密码,以便我有权完成上述恢复

但是为了让MongoDB对用户进行身份验证,还提供了
-d
选项,让MongoDB知道使用哪个数据库对用户进行身份验证

由于我使用了
-d
,mongorestore抱怨如下:

the --db and --collection args should only be used when restoring from
a BSON file. Other uses are deprecated and will not exist in the future;
use --nsInclude instead
我尝试使用
--nsInclude
而不是建议的
-d
,但是当我这样做时,mongorestore无法再验证用户身份,操作失败

下面是完整命令行的外观:

mongorestore -h "myhost" -u myUserName -p myPassword -d myDatabaseName --drop --archive=dump.zip --gzip --nsInclude myDatabaseName.*

那么,我们应该如何停止使用不推荐的
-d
选项,并且仍然能够对恢复进行身份验证以完成恢复呢?

您要找的不是
-d

指定要还原到的数据库。出于身份验证目的,这些不是您要查找的参数

在MongoDB 3.4及更新版本中,
-d
参数被和取代,因为它们更能描述意图