我正在为 Ubuntu 14.04 运行最新的 MongoDB
- 我已经创建了一个名为“admin”且具有“userAdminAnyDatabase”角色的用户
- 我可以访问本地和外部的数据库
- 我可以使用 SHA-SCRAM-1 使用“admin”登录
当我编辑配置文件以仅通过身份验证来限制访问时,出现了问题。发生了什么:
- 我在配置文件中取消注释“#auth = true”。
- 我无法使用“管理员”帐户的正确凭据进行访问。
请记住,我在进行更改后确实使用了“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:
数据库快照供引用:
出了什么问题?
最佳答案
我认为 auth = true
是一个无效配置,因此您的 mongod 没有启动。启用 authorization , 请尝试使用以下内容:
security:
authorization: enabled
然后,要连接到数据库,请确保您的客户端使用正确的 authentication database and authentication mechanism .这可以通过以下命令使用命令行来完成:
mongo localhost -u admin -p myAdminPass --authenticationDatabase admin --authenticationMechanism SCRAM-SHA-1
关于mongodb - 无法连接到启用身份验证的 MongoDB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33287559/