Search code examples
mongodbcentos6.5

can't start mongodb when open auth on mongod.conf


i can't start mongod when i uncomment "security:authorization:enabled" options on /etc/mongod.conf ? on mongodb 3.4.2 on centos6.5;

this is the commond print out :

sudo service mongod restart
Stopping mongod:                                           [  OK  ]
Starting mongod:                                           [FAILED]

this is my mongod.conf file: here is the commond print out :

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# Where and how to store data.
storage:
  dbPath: /var/lib/mongo
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# how the process runs
processManagement:
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile

# network interfaces
net:
  port: 58018
  bindIp: 127.0.0.1  # Listen to local interface only, comment to listen on all interfaces.

#security:                <---uncomment here will start failed
#  authorization:enabled  <---uncomment here will start failed
#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options

#auditLog:

#snmp:

Solution

  • Everything is okay you are just missing a space before enabled keyword . Space is very important before enabled

    ```

    security:
      authorization: enabled
    

    ```

    Replace your snippet with the above snippet for security . It is hard to find and hopefully will help somebody .