Skip to content

Instantly share code, notes, and snippets.

@eng-atwijukire
Forked from shivampip/mongodb_pass_reset.md
Created March 26, 2021 13:02
Show Gist options
  • Save eng-atwijukire/0953f9919d06340e936338769720828a to your computer and use it in GitHub Desktop.
Save eng-atwijukire/0953f9919d06340e936338769720828a to your computer and use it in GitHub Desktop.
MongoDB shell admin password reset
  • open mongod.conf
cd /etc/mongod.conf
  • Comment security
#security:
#  authroization: "enabled"
  • Restart mongodb
sudo service mongod stop
sudo service mongod start
  • Run mongo
mongo
  • Run these cmds
use admin
db.createUser({user:"admin",pwd:"password",roles:[{role:"root",db:"admin"}]});
  • Enable auth again what you had commented in /etc/mongod.conf file (remove comments)

  • Restart mongod service again

  • DONE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment