简体   繁体   English

MongoDB:无法添加用户 - 未授权 (CloudFoundry)

[英]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.

相关问题 错误:无法添加用户:未授权测试执行命令 { createUser: - Error: couldn't add user: not authorized on test to execute command { createUser: MongoDB:“无法添加用户:找不到角色” - MongoDB : "Couldn't add user : Could not find role" 在 mongdb 集群上创建第一个管理员用户时出现错误“无法添加用户:管理员无权执行命令” - When creating first admin user on mongdb cluster getting error “couldn't add user: not authorized on admin to execute command” 未授权MongoDB用户 - MongoDB User Is Not Authorized To MongoDB - 管理员用户未授权 - MongoDB - admin user not authorized “错误:无法添加用户”在 MongoDB docker 堆栈中使用 Windows 上的机密文件 - “Error: couldn't add user” in MongoDB docker stack using a secrets file on Windows Mongodb 4.2 未捕获异常:错误:无法添加用户:命令 createUser 需要身份验证 - Mongodb 4.2 uncaught exception: Error: couldn't add user: command createUser requires authentication 错误:无法添加用户:没有名为 root@test 的角色 - Error: couldn't add user: No role named root@test MongoDB-未经沙箱计划授权的管理员用户 - MongoDB - admin user not authorized on sandbox plan Docker 中的 Mongo ReplicaSet - 无法添加用户:不是主 - Mongo ReplicaSet in Docker - couldn't add user: not master
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM