MongoDB 客户端访问控制:SCRAM-SHA-1 身份验证失败,存储密钥不匹配 [英] MongoDB Client Access Control: SCRAM-SHA-1 authentication failed, storedKey mismatch

查看:29
本文介绍了MongoDB 客户端访问控制:SCRAM-SHA-1 身份验证失败,存储密钥不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在本地 Mongo 安装上激活用户授权,但身份验证一直失败.可能是什么问题?我错过了什么吗?

I'm trying to activate user authorization on my local Mongo installation, but authentication keeps on failing. What can be the problem? Am I missing something?

我按照在 Windows 上安装" 和 "启用客户端访问控制:

1) 添加了一个用户

>mongo admin
MongoDB shell version: 3.2.7
connecting to: admin
> db.createUser({createUser:"admin",pwd:"admin",roles:["root"]})
Successfully added user: { "createUser" : "admin", "roles" : [ "root" ] }
>

2) 在 mongod.cfg 中启用客户端访问控制:

2) Enabled Client Access Control in mongod.cfg:

systemLog:
    destination: file
    path: c:\data\log\mongod.log
storage:
    dbPath: c:\data\db
security:
    authorization: enabled

3) 重启mongod

4) 现在使用正确"凭据(我刚刚指定的凭据)登录总是失败:

4) Now logging in with the "right" credentials (the ones I just specified) always fails:

>mongo admin -u admin -p admin
MongoDB shell version: 3.2.7
connecting to: admin
2016-06-14T12:25:02.376+0200 E QUERY    [thread1] Error: Authentication failed. :
DB.prototype._authOrThrow@src/mongo/shell/db.js:1441:20
@(auth):6:1
@(auth):1:2

exception: login failed

日志文件中的错误是:SCRAM-SHA-1 authentication failed for admin on admin from client 127.0.0.1 ;AuthenticationFailed: SCRAM-SHA-1 认证失败,storedKey 不匹配

平台是 Windows 10 x64,如果这很重要的话.MongoDB 64 位 3.2.7 与 OpenSSL.

Platform is Windows 10 x64, if that matters. MongoDB 64-bit 3.2.7 with OpenSSL.

推荐答案

As 根据文档,传递给 createUser 的对象应该包含一个 user 属性(以及其他属性):

As per the documentation, the object passed to createUser should contain a user property (along with the others):

db.createUser({ user : "admin", pwd : "admin", roles : ["root"] })
                ^^^^ not `createUser`

这篇关于MongoDB 客户端访问控制:SCRAM-SHA-1 身份验证失败,存储密钥不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆