Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongodb start error with security.authorization enabled

Tags:

macos

mongodb

I am getting an error attempting to start mongo with authorization enabled via the security.authorization configuration parameter (see http://docs.mongodb.org/manual/reference/configuration-options/#security.authorization)

On running mongod I get

Error parsing INI config file: unknown option security.authorization
try 'mongod --help' for more information

Any idea? Thanks

Supporting data:

  • Mongo version 2.6.0 (installed via homebrew)
  • OSX Mavericks 10.9.2

start command:

mongod -f /usr/local/etc/mongod.conf

mongod.conf file (works fine if I comment out security.authorization):

# Store data in /usr/local/var/mongodb instead of the default /data/db
dbpath = /usr/local/var/mongodb

# Append logs to /usr/local/var/log/mongodb/mongo.log
logpath = /usr/local/var/log/mongodb/mongo.log
logappend = true

# Only accept local connections
bind_ip = 127.0.0.1

# auth
security.authorization = enabled
#security.authenticationMechanisms = MONGODB-CR  #error occurs with or without this

No entry is made in the mongo.log file when this occurs

like image 605
Cargo Cult Avatar asked Apr 14 '14 04:04

Cargo Cult


People also ask

How do I disable authorization in MongoDB?

Disconnect from the mongo shell ( Ctrl+D ). Locate the following code in the mongod configuration file ( /etc/mongod.conf ). Change authorization disabled to enabled and save the file. Restart MongoDB using the following code.

What is authentication in MongoDB?

Authentication -- the process of verifying the identity of a user -- is therefore one of the most important and central features of MongoDB. The main purposes of authentication are: Requiring that all clients and servers provide valid credentials to connect to the system. Restricting users to only perform actions as determined by their roles.

How secure is MongoDB Atlas and MongoDB server?

MongoDB Atlas and MongoDB Server provide a variety of authentication mechanisms that allow users to secure their deployment, from a simple username/password authentication to a full enterprise-grade authentication mechanism, like LDAP and Kerberos.

How do I connect to a Mongo database?

Start MongoDB without authentication (default no authentication configuration). Connect to the server using the mongo shell from the server itself. Note: The port is usually set to 27017. Create an administrator in the admin database with a userAdminAnyDatabase role.


1 Answers

Note: I would have written this as a comment, however I do not have the points yet.

Just wondering whether what you are trying to achieve is authentication instead? If this is the case, all you need to set in mongodb.conf is:

# auth
auth = true   # true or false. Whether or not authentication is required. 

-- UPDATED:

Some other steps that are important:

Configure the db location: Set in mongodb.conf as (you already have this, but should check the directory and permissions exist):

# Store data in /usr/local/var/mongodb instead of the default /data/db
dbpath = /usr/local/var/mongodb

# Append logs to /usr/local/var/log/mongodb/mongo.log
logpath = /usr/local/var/log/mongodb/mongo.log
logappend = true

Dont forget to make sure the above /usr/local/var/mongodb directory and /usr/local/var/log/mongodb/ directory exist. The installer that you used may not have made them.

Create an Operating System user for mongodb: (If one has not already been created - this is how on linux, not sure for osx) - as root:

adduser --system --no-create-home --disabled-login --disabled-password --group mongodb

Add permissions to folders if they are not already set:

chown mongodb:mongodb -R /usr/local/var/mongodb

To setup database user authorization / privileges:

See the command reference here: http://docs.mongodb.org/manual/reference/command/#database-commands

like image 65
jdt Avatar answered Sep 20 '22 09:09

jdt