在 mongod.conf 上打开身份验证时无法启动 mongodb

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

当我取消注释 /etc/mongod.conf 上的 "security:authorization:enabled" 选项时,我无法启动 mongod? 在 mongodb 3.4.2 在 centos6.5 上;

这是常见的打印输出:

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

这是我的 mongod.conf 文件: 这是常见的打印输出:

# 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:

一切正常,您只是在 enabled 关键字之前缺少 space。 Space启用前很重要

```

security:
  authorization: enabled

```

为了安全起见,请将您的代码段替换为上述代码段。 很难找到,希望能帮助别人。

我正在使用 'MongoDB server version: 3.6.5',这个对我有用:

security.authorization: enabled