这是我的mongo.conf
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
net:
port: 27017
bindIp: 0.0.0.0
security:
authorization: enabled
我通过systemctl启动它,这样做:
/usr/bin/mongod --quiet --auth --config /etc/mongod.conf
像这样创建了一个管理员用户:
mongo
> use admin
> db.createUser({ user:"user001", pwd:"pwd001", roles:[{role:"root", db:"admin"}]})
我可以通过以下方式访问EC2上的mongo:
mongo -u user001 -p pwd001 --authenticationDatabase admin
然而,当我尝试通过我的本地访问它时:
mongo -u user001 -p pwd001 --authenticationDatabase admin --host 58.17.53.6
我收到此错误:
MongoDB shell version: 3.0.4
connecting to: 58.17.53.6:27017/test
2017-10-30T19:42:33.302-0700 W NETWORK Failed to connect to 58.17.53.6:27017 after 5000 milliseconds, giving up.
2017-10-30T19:42:33.304-0700 E QUERY Error: couldn't connect to server 58.17.53.6:27017 (58.17.53.6), connection attempt failed
at connect (src/mongo/shell/mongo.js:181:14)
at (connect):1:6 at src/mongo/shell/mongo.js:181
exception: connect failed
任何帮助将不胜感激!