mongodb 添加用户名密码验证

来源:互联网 发布:ubuntu谷歌拼音输入法 编辑:程序博客网 时间:2024/05/21 10:59

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
原创粉丝点击