MongoDB: set user/password to access to db MongoDB: set user/password to access to db mongodb mongodb

MongoDB: set user/password to access to db


From your comment you mention that you are using mViewer. Version 0.9.1 of mViewer does not support authentication. According to this issue on the mViewer GitHub, this is resolved in version 0.9.2, which was targeted for release in Oct.

Before starting the node with authentication, log on to the node and add a user. Then start the node with --auth and connect to the shell without mViewer.

At this point you can connect to the admin database and authenticate your admin user:

use admindb.auth('root', 'root')

Since you set up an admin user, which will have access to all the databases, you need to authenticate against the admin database. Once you have done this you will have access to all the databases. You will also be able to create new users on any database, or create new read only users for all the databases.

If you create a new user that has access to only one database, that user would need to use that database and db.auth(name, pass) against it.

If you create a new user that has read only access to all databases, they would use admin and then db.auth(name, pass) to gain their read only access to all databases

You can find more information on setting up authentication here and more information about setting up users here

Note: When you start a node without --auth then no authentication is enabled. This means you can connect with the shell and db.auth('root','root') but it won't do anything as far as access is concerned. MongoDB will not deny access to the databases without --auth command line option (--keyFile in sharded setups or replica sets)