我可以使用shell命令在mongodb上进行身份验证:
#mongo -u user -p pwd --authenticationDatabase admin
MongoDB shell version v3.4.1
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.1
> use admin
switched to db admin
> show users
{
"_id" : "admin.ladmin",
"use
我使用mongorestore命令行将gzip转储还原到数据库。
在我的MongoDB实例上启用了安全性,因此我需要向命令行提供用户名和密码,以便授权我完成上述恢复。
但是对于MongoDB对用户进行身份验证,还为MongoDB提供了-d选项,以了解要使用哪个数据库对用户进行身份验证。
由于我使用的是-d,所以mongorestore使用以下内容进行抱怨:
the --db and --collection args should only be used when restoring from
a BSON file. Other uses are deprecated and will n
我已经将Java MongoDB客户端配置为使用MongoCredential。不幸的是,当我访问未配置为使用身份验证的服务器时,我会得到身份验证失败的异常:
Caused by: com.mongodb.MongoCommandException: Command failed with error 18: 'Authentication failed.' on server …. The full response is { "ok" : 0.0, "code" : 18, "errmsg" : "Authentica