https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
Note: I was getting this error "E: Unable to locate package mongodb-org" in order to resolve this issue i had to modify this line echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
mongo --version service mongod start service mongod stop service mongod restart
/etc/mongod.conf
#Enable Authentication https://medium.com/mongoaudit/how-to-enable-authentication-on-mongodb-b9e8a924efac
I used this command to addUser with Root role
db.createUser(
{
user: "root",
pwd: "password",
roles:["root"],
passwordDigestor: "server"
}
)
use admin // select Db
db.auth("root", "password")
db.dropUser('user') // Remove user
db.dropAllUsers({})
db.getUsers({}) // get all the users