Turning on Authentication

Once the user administrator account has been created, you need to restart the MongoDB database by using the --auth parameter, like this:

mongod –dbpath <mongo_data_location>/data/db --auth

Clients now have to use a username and password to access the database. Also, when you access MongoDB from the shell, you need to execute the following commands to authenticate to the admin database so that you can add users with rights to the databases:

use admin
db.auth("useradmin", "test")

You can also authenticate to the admin database when you start the MongoDB shell by using the --username and --password options and specifying the admin database, as in this example:

mongo admin --username "useradmin " --password "test"

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.168.46