安裝 MongoDB
curl -s https://raw.githubusercontent.com/oscm/shell/master/database/mongodb/mongodb.org/mongodb-4.0.2.sh | bash
創建管理和資料庫用戶
# mongo use admin; db.createUser( { user: "admin", pwd: "chen", roles: [ "dbAdmin", "dbOwner", "userAdmin" ] } ); use products db.createUser( { user: "accountUser", pwd: "password", roles: [ "readWrite", "dbAdmin" ] } )
開啟認證
curl -s https://raw.githubusercontent.com/oscm/shell/master/database/mongodb/mongodb.org/security.authorization.enabled.sh | bash