I installed MongoDB 3.2 and I enabled authentication:

  authorization: enabled

I created an admin user with the following command in the terminal:

mongo admin --eval 'db.createUser({user:"admin",pwd:"password",roles:["root"]})'

Then I created new database and a user for this database using the following command:

mongo -u admin -p password admin --eval 'db.getSiblingDB("shop").createUser({user:"shop_user",pwd:"password",roles:["dbOwner"]})'

Everything seem to be working. When I'm logged in with the shop_user user I can do everything in the shop database and I can only see this database. But when I'm logged in with the admin user I cannot see the shop database. Since the admin user has the root role, I assume I should be able to see all the databases in my system, but the shop database is hidden from me.

Does anybody know what is happening and how I can make the admin user see all databases?

  • 1
    I re-pro your steps and I was able to access shop database with both admin and shop_user. When you log in with admin, did you specify to use shop database with use shop?
    – Howard Lee
    Commented Mar 21, 2016 at 21:34
  • 1
    Also, you may want to post output of use admin; show users and use shop; show users
    – Howard Lee
    Commented Mar 21, 2016 at 22:47

1 Answer 1


This is because you have not restarted your MongoDB instance in auth mode. Restart your MongoDB in auth mode in linux like this

mongod --auth --fork --logpath /var/log/mongod.log

Reference: Enable Auth

Remember if you have enabled auth mode for your MongoDB instance, you must have put it in your code and start the mongod process in auth mode.

To simplify this (authenticating the db) use Studio 3T (MongoDB Client) but you still need to start the instance with the --auth command line option.

  • What if I installed mongoDB as a daemon on Ubuntu 18 and restart it using sudo systemctl restart mongodb? How do I ensure it is started in auth mode always from now on, since I've enabled authorization in the config? Commented Sep 30, 2019 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.