Save Preloader image

0%

https://pedalsup.com/wp-content/uploads/2020/06/blog-header-bg-min-1.png

Latest News

Building the brands stronger and take you to
the next level of business!

Secure Database with user roles in MongoDB

By Jimish Parekh
41

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” ]
})

You can get more information about roles here.

Happy Coding!