Custom command
1. connect database mongo localhost mặc định:
mongosh
hoặc
mongosh "mongodb://localhost:27017"
2. tạo các user:
db.createUser({user: "namlong",pwd: "h23@#Hba",roles: [ { role: "readWrite", db: "namlong" } ]})
db.createUser({user: "namlongadmin",pwd: "h23@#Hba",roles:[{role: "userAdminAnyDatabase" , db:"admin"}]})
db.createUser({user: "namlongadmin1",pwd: "h23@#Hba",roles:[{role: "userAdmin" , db:"namlong"}]})
3. connect database bằng user mới tạo:
mongosh "mongodb://localhost:27017/namlong" --username namlongadmin1 --password h23@#Hba --authenticationDatabase namlong
No comments:
Post a Comment