Answers for "mongo show user and password"

1

connect to mongodb with username and password

->First run mongoDB on terminal using
mongod

->now run mongo shell use following commands

    use admin
db.createUser(
  {
    user: "myUserAdmin",
    pwd: "abc123",
    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
  }
)

->Re-start the MongoDB instance with access control.
mongod --auth

->Now authenticate yourself from the command line using
mongo --port 27017 -u "myUserAdmin" -p "abc123" --authenticationDatabase "admin"

->You can read it from
https://docs.mongodb.com/manual/tutorial/enable-authentication/
Posted by: Guest on April-13-2021
-1

mongo show users

db.getUsers()
Posted by: Guest on August-14-2020

Code answers related to "mongo show user and password"

Browse Popular Code Answers by Language