How can I enter Mongo as a superuser or reset users?

How can I enter Mongo as a superuser or reset users?

  • I'm was playing around with permissions and locked myself out of Mongo database. I'm pretty sure I did this by trying to explicitly add access to a database but instead I overwrote only allowing permission to the database. So I'm effectively locked out of my Mongo database and everything I read tells me how to create a super user if I have the add user privilege. Right now I don't think I have any users that have that privilege. Is there a way to enter the database as all access? I own the server and have root access.

  • Answer:

    If you have locked yourself out then you need to do the following: Stop your MongoDB instance Remove the --auth and/or --keyfile options from your MongoDB config to disable authentication Start the instance without authentication Edit the users as needed Restart the instance with authentication enabled

Tony at Database Administrators Visit the source

Was this solution helpful to you?

Other answers

Check the answers to this question, they might help http://stackoverflow.com/questions/20117104/mongodb-root-user Basically if you still have access to the server, you may be able to access the Admin database. There's more in this page http://docs.mongodb.org/v2.4/reference/user-privileges/ Note that 2.6 version changes how this works completely. For 2.6 you'll need to spend more time with http://docs.mongodb.org/manual/security/

Meligy

You have to stop Mongo, remove the admin files, then start Mongo sudo service mongod stop mv /data/admin.* . sudo service mongod start

Tony

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.