mongodb 驗證登陸

mongodb  驗證登陸mongodb


Start MongoDB without access control.shell


mongod --port 27017 --dbpath /data/db1ide




Connect to the instance.rest


For example, connect a mongo shell to the instance.it


mongo --port 27017io



Create the user administrator.class


In the admin database, add a user with the userAdminAnyDatabase role. For example, the following creates the user myUserAdmin in the admin database:登錄



use admindb

db.createUser(tab

  {

    user: "myUserAdmin",

    pwd: "abc123",

    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]

  }

)


restart mongodb instance


mongod --auth --port 27017 --dbpath /data/db1


mongo --port 27017 -u "myUserAdmin" -p "abc123" --authenticationDatabase "admin"

相關文章
相關標籤/搜索