MongoDB“根"用户 [英] MongoDB "root" user

查看:23
本文介绍了MongoDB“根"用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MongoDB 有没有像root"这样的超级 UNIX 用户?我一直在看 http://docs.mongodb.org/manual/reference/user-privileges/ 并尝试了很多组合,但它们似乎都在某个方面有所欠缺.肯定有一个角色高于此处列出的所有角色.

Is there a super UNIX like "root" user for MongoDB? I've been looking at http://docs.mongodb.org/manual/reference/user-privileges/ and have tried many combinations, but they all seem to lack in an area or another. Surely there is a role that is above all the ones listed there.

推荐答案

虽然开箱即用,MongoDb 没有身份验证,但您可以通过对特定用户使用any"角色来创建 root/超级用户的等效项admin 数据库.

While out of the box, MongoDb has no authentication, you can create the equivalent of a root/superuser by using the "any" roles to a specific user to the admin database.

像这样:

use admin
db.addUser( { user: "<username>",
          pwd: "<password>",
          roles: [ "userAdminAnyDatabase",
                   "dbAdminAnyDatabase",
                   "readWriteAnyDatabase"

] } )

2.6+ 更新

虽然 2.6 中有一个新的 root 用户,您可能会发现它不能满足您的需求,因为它仍然有一些限制:

Update for 2.6+

While there is a new root user in 2.6, you may find that it doesn't meet your needs, as it still has a few limitations:

提供对操作和所有资源的访问readWriteAnyDatabase、dbAdminAnyDatabase、userAdminAnyDatabase 和clusterAdmin 角色组合.

Provides access to the operations and all the resources of the readWriteAnyDatabase, dbAdminAnyDatabase, userAdminAnyDatabase and clusterAdmin roles combined.

root 不包括对以系统.前缀.

root does not include any access to collections that begin with the system. prefix.

3.0+ 更新

Use db.createUser 因为 db.addUser 已被删除.

root 不再有上述限制.

root 在系统上具有验证权限操作.集合.以前,root 不包括对以与系统.system.indexes 以外的前缀和system.namespaces.

The root has the validate privilege action on system. collections. Previously, root does not include any access to collections that begin with the system. prefix other than system.indexes and system.namespaces.

这篇关于MongoDB“根"用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆