reset mongodb password1 min read


Hi Techrunnr, this document deals with reset password and authentication setup of mongoDB, this document helps you to work with when you forget mongodb user (include super user too) credentials

For MongoDB authentication setup please go through the our blog link:

To reset the mongodb authentication setup, first we need to edit the mongod.conf file, authentication setup block looks like as shown below

  authorization: enabled

Now we need to disable this authentication setup

#  authorization: enabled
  • Restart the mongod service
    systemctl restart mongod
  • Now login to mongodb, and create a super user or else a normal user, here we are creating a super user with root privileges
    >use admin
    user: 'techrunnr1',
    pwd: 'techrunnr',
    roles: [ { role: 'root', db: 'admin' } ]

  • Now we have created a super user, Now we can setup the mongodb authentication setup, for this we need to edit mongd.conf file and uncomment the security section and restart the mongod service
      authorization: enabled
    systemctl restart mongod

    Authentication setup done, Now try to login using the newly created user name and password

  • Use below command to login
    mongo -u techrunnr1 --authenticationDatabase "admin" -p





We need your support!!
Other Amount:
Questions Answered
Articles Written
Overall Points

You may also like...

Leave a Reply