MongoDB的"root"用户用户 [英] MongoDB "root" user
问题描述
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/superuser的权限. 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 does not include any access to collections that begin with the system. prefix.
更新为3.0 +
使用db.createUser
,因为db.addUser
已被删除.
Update for 3.0+
Use db.createUser
as db.addUser
was removed.
root 不再具有上述限制.
root no longer has the limitations stated above.
根在系统上具有validate特权操作.集合. 以前,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的"root"用户用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!