[英]MongoDB: Couldn't add user - not authorized (CloudFoundry)
I have a MongoDB (Service Plan: small) and I would like to create an additional user but it seems I dont have the necessary privileges to do so.我有一个 MongoDB(服务计划:小),我想创建一个额外的用户,但我似乎没有这样做的必要权限。
db.createUser({ user: "whateverusername" , pwd: "whateverpassword", roles: ["userAdminAnyDatabase", "dbAdminAnyDatabase", "readWriteAnyDatabase"]})
Failed to execute script.
无法执行脚本。
Error: couldn't add user: not authorized on XXXXXXX to execute command { createUser: "whateverusername", pwd: "xxx", roles: [ "userAdminAnyDatabase", "dbAdminAnyDatabase", "readWriteAnyDatabase" ], digestPassword: false, writeConcern: { w: "majority", wtimeout: 600000.0 } } : _getErrorWithCode@src/mongo/shell/utils.js:25:13 DB.prototype.createUser@src/mongo/shell/db.js:1290:15 @(shell):1:1
错误:无法添加用户:XXXXXXX 未授权执行命令 { createUser: "whateverusername", pwd: "xxx", roles: [ "userAdminAnyDatabase", "dbAdminAnyDatabase", "readWriteAnyDatabase" ],digestPassword: false, writeConcern: { w: "majority", wtimeout: 600000.0 } } : _getErrorWithCode@src/mongo/shell/utils.js:25:13 DB.prototype.createUser@src/mongo/shell/db.js:1290:15 @(shell ):1:1
and I cant list the users:我无法列出用户:
db.system.users.find();
Error: error: { "ok" : 0, "errmsg" : "not authorized on XXXXXXX to execute command { find: \\"system.users\\", filter: {} }", "code" : 13, "codeName" : "Unauthorized" }
错误:错误:{“ok”:0,“errmsg”:“未授权在 XXXXXXX 上执行命令 { 查找:\\“system.users\\”,过滤器:{} }”,“代码”:13,“代码名称” :“未经授权”}
Is this restriction intended?这个限制是有意的吗? Is there a way to get the readWriteAnyDatabase role?
有没有办法获得 readWriteAnyDatabase 角色? Am I doing something wrong?
难道我做错了什么?
I really appreciate any help you can provide!我非常感谢您能提供的任何帮助!
You need to add users through CloudFoundry.您需要通过 CloudFoundry 添加用户。 Either bind the service to an app, which will create a user to be used by that app, or create a service key which is meant for all other purposes (mostly for the cases where a human needs to interact with the database).
要么将服务绑定到一个应用程序,这将创建一个由该应用程序使用的用户,要么创建一个用于所有其他目的的服务密钥(主要用于人类需要与数据库交互的情况)。
Here's the docs on how to bind a service to an app: https://docs.developer.swisscom.com/devguide/services/application-binding.html以下是有关如何将服务绑定到应用程序的文档: https : //docs.developer.swisscom.com/devguide/services/application-binding.html
A tutorial for it: https://docs.developer.swisscom.com/tutorial-go/bind-service.html它的教程: https : //docs.developer.swisscom.com/tutorial-go/bind-service.html
And here's how to create service keys: https://docs.developer.swisscom.com/devguide/services/service-keys.html以下是创建服务密钥的方法: https : //docs.developer.swisscom.com/devguide/services/service-keys.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.