且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MongoDB-CR 身份验证失败

更新时间:2021-09-01 00:56:27

转到 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.