我的 /etc/mongod.conf 中有以下内容:
# set parameter options
setParameter:
enableLocalhostAuthBypass: false
# security options
security:
authorization: enabled
#keyFile: replace_me
我已使用systemctl restart mongod
并检查了 /var/log/mongodb/mongod.log 重新启动了 mongod 服务。最近有一行关于已读取配置且设置生效的内容:
{
"t": { "$date": "2023-11-26T10:39:15.483+00:00" },
"s": "I",
"c": "CONTROL",
"id": 21951,
"ctx": "initandlisten",
"msg": "Options set by command line",
"attr": {
"options": {
"config": "/etc/mongod.conf",
"net": {
"bindIp": "*",
"ipv6": false,
"port": 27017,
"tls": {
"certificateKeyFile": "/etc/ssl/mongodb.pem",
"mode": "requireTLS"
}
},
"processManagement": {
"fork": false,
"pidFilePath": "/var/lib/mongodb/mongodb.pid"
},
"security": { "authorization": "enabled" },
"setParameter": { "enableLocalhostAuthBypass": "false" },
"storage": { "dbPath": "/var/lib/mongodb", "directoryPerDB": false },
"systemLog": {
"destination": "file",
"logAppend": true,
"logRotate": "reopen",
"path": "/var/log/mongodb/mongod.log",
"quiet": false,
"verbosity": 0
}
}
}
}
看来我的设置已经生效了。为什么我不用用户名和密码仍然可以登录我的 mongod 服务?