how to retrieve mongodb admin password installed on AWS EC2 3rd party developers have installed MongoDB on AWS EC2 instance and later handed over code to me.

Now I don't know what's the password for admin user of MongoDB but I do have ssh keys to connect to that EC2 instance.

My query is how to reset password for MongoDB admin user ?
You can't retrieve existing passwords, but you can reset them assuming you have ssh access to the host and appropriate root or sudo permissions to edit the MongoDB configuration and restart the MongoDB service.

The exact steps may vary depending on your O/S and how you manage the MongoDB server, but the general process for resetting a password on a standalone MongoDB server would be:


Take a backup of the configuration file used by your used by your MongoDB service (typically /etc/mongod.conf for Linux installations).
Edit the current configuration file to set:


security.authorization to disabled
net.bindIp to localhost (you don't want to allow remote connections while access control is disabled)

Restart your MongoDB service using the relevant command for your O/S (typically sudo service mongod restart in Linux).
Login to mongod locally without auth using the mongo shell: mongo localhost/admin.
Reset the password for your admin user: db.changeUserPassword('myAdminUser','New&amp;secur3').
Replace your MongoDB configuration file with the original that you backed up in the first step.
Restart the service: sudo service mongod restart.