How to create User and add Role in MongoDB?
Creating Admin User
We can create a user administrator in MongoDB by using the createUser method. e.g:
db.createUser(
{
user: "myadmin",
pwd: "password@123",
roles:[{role: "userAdminAnyDatabase", db:"admin"}]
});
Creating Admin User
We can create a user administrator in MongoDB by using the createUser method. e.g:
db.createUser(
{
user: "myadmin",
pwd: "password@123",
roles:[{role: "userAdminAnyDatabase", db:"admin"}]
});