1. Connect DB แล้ว run command ตามโน้น
use admin
db.createUser(
{
user: "myUserAdmin",
pwd: passwordPrompt(), // or cleartext password
roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
}
)
2. Shutdown Mongo
db.adminCommand( { shutdown: 1 } )
3. Add config mongod.conf ตามนี้
security:
authorization: enabled
4. Start mongo