MongoDB-CR身份验证失败 [英] MongoDB-CR Authentication failed

查看:90
本文介绍了MongoDB-CR身份验证失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在验证用户时遇到以下错误:purchase_user @ purchase失败. MongoDB-CR身份验证失败.通过浏览器访问Web服务时,用户文档中的凭证丢失.

I am getting following error while authenticating user : purchase_user@purchase failed. MongoDB-CR Authentication failed. Missing credentials in user document when I access webservice through browser.

但是我能够从mongo验证purchase_user,它返回1.

But I am able to authenticate purchase_user from mongo it returns 1 .

推荐答案

转到mongoDB控制台并删除当前用户&将authSchema版本设置为3而不是5,在mongo控制台中遵循以下命令-

go to mongoDB console and delete your current user & set authSchema version to 3 instead of 5 , follow these commands in mongo console -

mongo
use admin
db.system.users.remove({})    <== removing all users
db.system.version.remove({}) <== removing current version 
db.system.version.insert({ "_id" : "authSchema", "currentVersion" : 3 })

现在重新启动mongod并创建新用户,然后它将正常工作.

Now restart the mongod and create new user then it should work fine.

注意:如果在生产环境中使用update,则仅在test db中使用remove命令.

Note: use remove commands in test db only, if in production use update.

如果您删除所有用户,并且在配置中启用了身份验证(或在Kubernetes掌舵图中默认设置的--auth参数),则无法再访问MongoDB.禁用身份验证,创建新用户然后重新启用它是必需的.

If you delete the all users and authentication is enabled in the configuration (or --auth param which is set per default on the Kubernetes helm chart), it's not possible to access MongoDB any more. Its required to disable authentication, create a new user and then re-enable it.

在Kubernetes上,您需要编辑参数并添加--noauth作为参数,因为它不是经典安装的MongoDB上的默认值.有关更多信息,请参阅 CLI文档 --noauth和相应的--auth.

On Kubernetes you need to edit the parameters and add --noauth as argument, since it's not the default there as on a classic installed MongoDB. Please see the CLI documentation for more information about --noauth and the corresponding --auth.

这篇关于MongoDB-CR身份验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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