MongoDB 客户端访问控制:SCRAM-SHA-1 身份验证失败,存储密钥不匹配
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37811036/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MongoDB Client Access Control: SCRAM-SHA-1 authentication failed, storedKey mismatch
提问by rustyx
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?
我正在尝试在本地 Mongo 安装上激活用户授权,但身份验证一直失败。可能是什么问题?我错过了什么吗?
I followed the steps outlined in "Installing on Windows" and "Enable Client Access Control":
我遵循了“在 Windows 上安装”和“启用客户端访问控制”中概述的步骤:
1) Added a user
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) Enabled Client Access Control in mongod.cfg
:
2) 启用客户端访问控制mongod.cfg
:
systemLog:
destination: file
path: c:\data\log\mongod.log
storage:
dbPath: c:\data\db
security:
authorization: enabled
3) Restarted mongod
3) 重新启动 mongod
4) Now logging in with the "right" credentials (the ones I just specified) always fails:
4)现在使用“正确”凭据(我刚刚指定的凭据)登录总是失败:
>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
The error in the logfile is: SCRAM-SHA-1 authentication failed for admin on admin from client 127.0.0.1 ; AuthenticationFailed: SCRAM-SHA-1 authentication failed, storedKey mismatch
日志文件中的错误是: SCRAM-SHA-1 authentication failed for admin on admin from client 127.0.0.1 ; AuthenticationFailed: SCRAM-SHA-1 authentication failed, storedKey mismatch
Platform is Windows 10 x64, if that matters. MongoDB 64-bit 3.2.7 with OpenSSL.
如果重要的话,平台是 Windows 10 x64。MongoDB 64 位 3.2.7 与 OpenSSL。
采纳答案by robertklep
As per the documentation, the object passed to createUser
should contain a user
property (along with the others):
根据文档,传递给的对象createUser
应该包含一个user
属性(以及其他属性):
db.createUser({ user : "admin", pwd : "admin", roles : ["root"] })
^^^^ not `createUser`
回答by Carlos Brito
Probably you're trying to recreate the database with new login and/or password. So, you need to exclude the "/db" folder. The database path's in the docker-compose.yml file. e.g.: "volumes: - ./db:/data/db".
可能您正在尝试使用新的登录名和/或密码重新创建数据库。因此,您需要排除“/db”文件夹。数据库路径在 docker-compose.yml 文件中。例如:“卷:- ./db:/data/db”。
回答by supertrens
I believe the password
you entered on db.createUser doesn't match the one you entered when prompting Enter password
in the mongo console. You can try to remove the user: db.dropUser('userName')
and recreate the user. Make sure you remember the correct password.
我相信password
您在 db.createUser 上输入的与您Enter password
在 mongo 控制台中提示时输入的不匹配。您可以尝试删除用户:db.dropUser('userName')
并重新创建用户。确保您记住正确的密码。