MongoDB Admin
Set/reset admin password
Make sure authentication is disabled in
/etc/mongod.conf
by settingsecurity authorization: disabled
or comment it out.Restart MongoDB using
sudo service mongod restart
Access the mongo shell commands using the terminal command
mongosh
this will start an interactive shell session.Type
db.getSiblingDB("admin").changeUserPassword("root", "PASSWORD")
and change PASSWORD to your choice, please use a random password with special characters.Type
exit
to exit the mongo shell.Enable authentication in
/etc/mongod.conf
by settingsecurity authorization: enabled
Restart MongoDB again
sudo service mongod restart
Last updated