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 ?
Best Answer
You can't retrieve existing passwords, but you can reset them assuming you have
ssh
access to the host and appropriate root orsudo
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:
/etc/mongod.conf
for Linux installations).security.authorization
todisabled
net.bindIp
tolocalhost
(you don't want to allow remote connections while access control is disabled)sudo service mongod restart
in Linux).mongod
locally without auth using themongo
shell:mongo localhost/admin
.db.changeUserPassword('myAdminUser','New&secur3')
.sudo service mongod restart
.