Skip to content

Instantly share code, notes, and snippets.

@koficoud
Forked from shivampip/mongodb_pass_reset.md
Last active July 21, 2023 07:27
Show Gist options
  • Save koficoud/00f496daed42bef0ed95c725a5771383 to your computer and use it in GitHub Desktop.
Save koficoud/00f496daed42bef0ed95c725a5771383 to your computer and use it in GitHub Desktop.
MongoDB shell admin password reset
  • open mongod.conf
sudo nano /etc/mongod.conf
  • Comment security
#security:
#  authroization: "enabled"
  • Restart mongodb
sudo service mongod restart
  • Run mongo
mongo
  • Run these cmds
use admin
db.updateUser("admin", {pwd:"password"});
  • 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