Man*_*ons 4 database authentication mongodb
我正在为Ubuntu 14.04运行最新的MongoDB
当我编辑配置文件以限制只有身份验证的访问时出错.怎么了:
请记住,我在进行更改后会使用"service mongod restart".
配置文件供参考:
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
#processManagement:
#security:
#auth = true
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
Run Code Online (Sandbox Code Playgroud)
数据库快照供参考:
出了什么问题?
我认为这auth = true是一个无效的配置,你的mongod没有因为它而启动.要启用授权,请尝试使用以下代码:
security:
authorization: enabled
Run Code Online (Sandbox Code Playgroud)
然后,要连接到数据库,请确保您的客户端使用正确的身份验证数据库和身份验证机制.这可以通过以下命令使用命令行完成:
mongo localhost -u admin -p myAdminPass --authenticationDatabase admin --authenticationMechanism SCRAM-SHA-1
Run Code Online (Sandbox Code Playgroud)