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: https://www.techrunnr.com/mongodb-create-user-authentication-setup-and-mongo-dump/

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

security:
  authorization: enabled

Now we need to disable this authentication setup

#security:
#  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
    mongo
    
    >use admin
    >db.createUser(
    {
    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
    security:
      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

 

 

 

 

© 2019, Techrunnr. All rights reserved.

#1
#2
#3
Questions Answered
Articles Written
Overall Points

0 Comments

Leave a Reply

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.