被我自己的mongodb实例锁定



我创建了两个用户,我认为他们是userAdmins。不幸的是,当我使用他们登录时,我的所有权限都被拒绝了。如果我在没有提供用户名或密码的情况下登录本地,我将被拒绝所有权限。我能做什么?

用户是使用以下命令创建的

use admin
db.createUser(
    {
      user: "Nikhil",
      pwd: "wouldntyouliketoknow",
      roles: ["userAdminAnyDatabase" ]
    }
)

userAdminAnyDatabase不是我想的意思吗?

我使用的是,您已经启用了授权安全性。为什么不将security.authorization设置为disabled并重新启动mongod?

http://docs.mongodb.org/manual/reference/configuration-options/

就你发出的命令而言,它看起来是不正确的,应该是这样的:

use admin
db.createUser(
  {
    user: "Nikhil",
    pwd: "wouldntyouliketoknow",
    roles: 
      [
        {
          role: "userAdminAnyDatabase",
          db: "admin"
        }
      ]
  }
)

请注意,您必须将一个包含角色和数据库的文档传递到调用中。

最佳起点在这里:http://docs.mongodb.org/manual/tutorial/enable-authentication/

此用户在所有数据库中都被限制为userAdmin角色。如果你想执行额外的操作,你需要授予自己额外的角色,或者创建一个拥有这些角色的新用户:

userAdminAnyDatabase
Provides the same access to user administration operations as userAdmin, except it applies to all databases in the cluster. The role also provides the following actions on the cluster as a whole:
authSchemaUpgrade
invalidateUserCache
listDatabases
The role also provides the following actions on the admin.system.users and admin.system.roles collections on the admin database, and on legacy system.users collections from versions of MongoDB prior to 2.6:
collStats
dbHash
dbStats
find
killCursors
planCacheRead
The userAdminAnyDatabase role does not restrict the permissions that a user can grant. As a result, userAdminAnyDatabase users can grant themselves privileges in excess of their current privileges and even can grant themselves all privileges, even though the role does not explicitly authorize privileges beyond user administration. This role is effectively a MongoDB system superuser.

http://docs.mongodb.org/manual/reference/built-in-roles/#built-在角色中

您可以简单地重新启动MongoDB,而不需要auth选项,它应该很乐意允许您登录并执行任何操作。

或者,您也可以为localhost身份验证启用旁路,并从运行MongoDB的同一主机进行连接。有关它的更多信息,请访问http://docs.mongodb.org/manual/core/authentication/#localhost-异常

根据您使用的MongoDB版本,上述步骤可能会有不同的行为,我建议您在上述网站上查找特定版本的文档。

最新更新