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

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

问题描述

我在验证用户时遇到以下错误:purchase_user@purchase failed.MongoDB-CR 身份验证失败.当我通过浏览器访问网络服务时,用户文档中缺少凭据.

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.

注意:仅在测试数据库中使用删除命令,如果在生产中使用更新.

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

如果您删除所有用户并在配置中启用身份验证(或 --auth 参数,该参数在 Kubernetes 掌舵图上默认设置),则无法再访问 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天全站免登陆