Sometimes we need to remove users from mongoDB which was added by mistake or no need of that users
So here I am going to explain steps to remove user from mongoDB
Step1. Disable security from mongodb.config /etc/mongodb.conf #Open mongod.conf file and commented “#security to security”.It’s normally located in /etc folder.Open the file as an administrator and modifie this file Step2. Disable security from mongodb.config /etc/mongodb.conf #sudo service mongod restart Step3. check status of mongo services #sudo service mongod restart Step4. Install mongochef & Connect to mongochef Step5. See all Dbs like(Admin, local, ...) Step6. Click on Admin dbs and see all collections(Collections, GridfsBuckets, Systems) Step7. click on Systems => click on sustem.users looks like below : { "_id" : "test_pocket_pass.prabhat", "user" : "prabhat", "db" : "test_pocket_pass", "credentials" : { "SCRAM-SHA-1" : { "iterationCount" : NumberInt(10000), "salt" : "uFNRtP3Qcdho5KP23SP65A==", "storedKey" : "oYqj+ga7uWl5KooCgBWhpK2noG4=", "serverKey" : "w9d5xSM90w99OCKQJq2pY3DfdPQ=" } }, "customData" : { }, "roles" : [ { "role" : "readWrite", "db" : "test_pocket_pass" } ] } Step8. Show in edit mode and remove all user keep only the user you created for your database with roles like above.
Step9. Enable security from mongodb.config /etc/mongodb.conf #Open mongod.conf file and uncomment “#security to security”.It’s normally located in /etc folder.Open the file as an administrator and modifie this file Step10. Restart mongo services