CONMISANMA的正確答案——MONGODB的權限問題

MONGODB DOC手冊 —— 啓用驗證

MONGODB DOC 手冊 —— 內置的角色(例如:userAdmin等)

 

原文:---------------------------------------------

Database Administration Roles

Every database includes the following database administration roles:

Role

Short Description
dbAdmin

Provides the ability to perform administrative tasks such as schema-related tasks, indexing, and gathering statistics. This role does not grant privileges for user and role management.

For the specific privileges granted by the role, see dbAdmin.

dbOwner The database owner can perform any administrative action on the database. This role combines the privileges granted by the readWritedbAdmin and userAdmin roles.
userAdmin

Provides the ability to create and modify roles and users on the current database. Since the userAdmin role allows users to grant any privilege to any user, including themselves, the role also indirectly provides superuser access to either the database or, if scoped to the admin database, the cluster.

For the specific privileges granted by the role, see userAdmin.

 

度娘機翻:-------------------------------------------

數據庫管理角色

每個數據庫包括數據庫管理角色:

的作用 簡短的描述
dbadmin

提供執行管理任務如 模式相關的任務,索引的能力,和收集統計。這個角色 不授予權限的用戶和角色管理。

對於具體的角色授予的特權,看dbadmin

dbowner 數據庫所有者可以在數據庫上執行的任何行政行爲。 這個角色權限的結合讀寫dbadminuseradmin角色。
useradmin

提供創建和修改的 當前數據庫角色和用戶的能力。自useradmin 用戶角色允許任何用戶授予任何特權,包括他們自己, 作用也間接超級用戶訪問任何數據庫或,如果限於admin數據庫集羣,the。

對於具體的角色授予的特權,看useradmin

 

這裏說明了userAdmin是沒readWrite權限的,需要加上readWrite權限才能在auth下 show collections

 

權限創建:

use admin

db.createUser(
    {

        user:'admin',
        pwd:'admin123',
        roles:
        [
            {role:'userAdmin',db:'admin'},
            {role:'readWrite',db:'admin'},
        ]

    }
)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章