Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set authorization in mongodb config file?

I run mongod.exe in server with this option in cmd.exe:

mongod.exe --dbpath=path --auth 

And now, how can I do this in a config file?
my mongod.cfg:

dbpath=D:\Program Files\MongoDB 2.6 Standard\data  security= authorization= enabled 

I get this error :

Error parsing INI config file: unknown option security.

like image 479
mlibre Avatar asked Aug 15 '14 10:08

mlibre


People also ask

How do I give a user permission in MongoDB?

MongoDB: db.grantRolesToUser() method is used to grants an additional role and its privileges to a user. The name of the user to whom to grant roles. An array of additional roles to grant to the user. The level of write concern for the modification.

What is authorization in MongoDB?

Authentication is the process of verifying the identity of a client. When access control (authorization) is enabled, MongoDB requires all clients to authenticate themselves in order to determine their access.

How do I restrict access to MongoDB?

To restrict MongoDB access by enabling authentication In the mongoconfiguration, set auth = true and restart the mongo service.


2 Answers

For mongod version 2.4 (ini config file)

auth = true 

https://docs.mongodb.com/v2.4/reference/configuration-options/#auth

For mongod versions 2.6+ (yaml config file)

security:     authorization: enabled 

https://docs.mongodb.com/v3.2/reference/configuration-options/#security.authorization https://docs.mongodb.com/v3.0/reference/configuration-options/#security.authorization https://docs.mongodb.com/v2.6/reference/configuration-options/#security.authorization

like image 88
Gary Avatar answered Sep 18 '22 07:09

Gary


mongodb version 3.2

this is the correct config

security:   authorization: "enabled" 

with quotes since the value is a string as per the documentation

like image 44
keithics Avatar answered Sep 22 '22 07:09

keithics