Skip to content

Instantly share code, notes, and snippets.

@getsueineko
Forked from shivampip/mongodb_pass_reset.md
Created September 24, 2021 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save getsueineko/c0dc74fa3c77d7abddd1d2fb0f4b6afb to your computer and use it in GitHub Desktop.
Save getsueineko/c0dc74fa3c77d7abddd1d2fb0f4b6afb 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