mongodb 新增使用者名稱密碼驗證
阿新 • • 發佈:2019-01-06
mongo localhost -u username -p pwd --authenticationDatabase admin --authenticationMechanism SCRAM-SHA-1
db.createUser( { user: "username", pwd: "passwrd", roles: [ { role: "readWrite", db: "shujuku" }, } )
shell建立使用者並登入
think that auth
= true
is an invalid configuration and your mongod is not starting because of it. To enable authorization,
try using the following instead:
security:
authorization: enabled
Then, to connect to the database, make sure that your client is using the correct authentication database and authentication mechanism. This can be done using the commmand line by the following command:
mongo localhost -u admin -p myAdminPass --authenticationDatabase admin --authenticationMechanism SCRAM-SHA-1