MongoDB-CR身份验证失败 [英] MongoDB-CR Authentication failed
问题描述
我在验证用户时遇到以下错误: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屋!