</>
Skip to content
MongoDB lessons (32/38)

MongoDB — Users

Create User

use mydb
db.createUser({
  user: "john",
  pwd: "password",
  roles: ["readWrite"]
})

List Users

db.getUsers()

Update User

db.updateUser("john", {
  roles: ["readWrite", "dbAdmin"]
})

Change Password

db.changeUserPassword("john", "newpassword")

Drop User

db.dropUser("john")

Roles

RoleDescription
readRead only
readWriteRead and write
dbAdminDatabase admin
userAdminManage users
rootFull access

Mini Practice

  1. Create a user
  2. List all users
  3. Update user roles
  4. Drop a user

Up Next

Continue with Backup — backup and recovery.

Related Topics

Frequently Asked Questions about Users

What is Users in MongoDB?

Users is a fundamental concept in MongoDB. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn Users?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Users.

Why is Users important in MongoDB?

Users is essential for MongoDB development. Understanding this concept will help you write better code and solve real-world problems more effectively.