mongodb-dba-workshop

The Localhost Exception

ทดลองรันคำสั่ง

mongod --auth

เป็นการบังคับให้ client ทุกตัวที่เชื่อมต่อเข้า daemon นี้ ต้องมีการผ่านการ Authenticate ทุกครั้ง

จากนั้นใช้ mongo shell ต่อเข้า mongod จะพบว่าเราไม่สามารถรันคำสั่งใดๆ ในการแก้ไขข้อมูลได้

use admin
db.createUser({ user: "pon", pwd: "pass", roles: [{role: "userAdminAnyDatabase", db: "admin"}]})

สังเกตว่า เรายังไม่สามารถแก้ไขข้อมูลได้เหมือนเดิม ต้องรันคำสั่ง authenticate user ก่อน

db.auth('pon','pass')

และสามารถดู User ได้

db.system.users.find()