# MongoDB
# 資料
- User authentication (opens new window)
- Commands (opens new window)
- mongod.conf setting (opens new window)
# ユーザの作成
# DB admin for any database
db.createUser({
user: "root",
pwd: ${ROOT_PASS},
roles:[
{ role: "dbAdminAnyDatabase", db: "admin" },
{ role: "readWriteAnyDatabase", db: "admin" },
{ role: "userAdminAnyDatabase", db: "admin" }
]
});
# DB admin for specific database
use some-specific-db
db.createUser( {
user: "john",
pwd: ${JOHN_PASS},
roles:[
{ role: "readWrite", db: "some-specific-db" }
]
});
# データベースへの接続
mongo www.something.com/admin -u root -p ${ROOT_PASS}
mongo www.something.com/some-specific-db -u john -p ${JOHN_PASS}
db.auth("user","pass")