Secure Database with user roles in MongoDB
This blog is about assigning roles to your particular database in MongoDB. If you have not secured your MongoDB please go to this blog and follow instructions.
Login & create a database
Create a database by simply using “use” command:
use demo
Create User
Create a user and assign them roles along with their credentials by following commands:
db.createUser({
user: “dbuser”,
pwd: “Pa$$Word”,
roles: [ “readWrite”, “dbAdmin” ]
})
Happy Coding!