Reference Guide

建立資料庫使用者
建立使用者,例如 DBUser 使用 Wyse 管理套件存取 MongoDB
: 以資料庫使用者和密碼範例,可在工作環境中使用不同名稱和密碼來建立
執行下列命令以建立 DBUser
db.createUser({
user: "DBUser",
pwd: <db_password>,
roles: [ { role: "userAdminAnyDatabase", db: "admin" },
{ role: "dbAdminAnyDatabase", db: "admin" },
{ role: "readWriteAnyDatabase", db: "admin" },
{ role: "dbOwner", db: "DBUser" }]
})
建立 MongoDB DBadmin 使用者
使用先前區段中建立的使用者帳戶登入 MongoDB使用管理權限建立 DBadmin 使用者
執行下列命令以建立 DBadmin 使用者:
mongo -uDBUser -pPassword admin
use admin
db.createUser( {
user: "DBadmin",
pwd: <DBadmin user password>,
roles: [ { role: "DBadmin", db: "admin" } ]
})
編輯 mongod.cfg 檔案
必須編輯 mongod.cfg 檔案以 MongoDB 資料庫的安全性
1. 建立的根使用者身分登入,並執行下列命令:
mongo -uroot -<root password> admin
2. 請前往 \data\bin\mongod.cfg 目錄,然後開文字編輯器中的 mongod.cfg 檔案
3. 如下列命令所示編輯 mongod.cfg 檔案:
56. 編輯 mongod.cfg
systemLog:
destination: file
path: c:\data\log\mongod.log
storage:
dbPath: c:\data\db\Mongo
60 MongoDB 上達到高可用性