我已按照这些步骤在我的Linux mint中安装MongoDB,最后运行此命令
mongo --host 127.0.0.1:27017
但运行此命令后出现此错误。
MongoDB shell version: 3.2.18
connecting to: 127.0.0.1:27017/test
2017-12-21T13:16:20.693+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused
2017-12-21T13:16:20.693+0530 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:231:14
@(connect):1:6
exception: connect failed
我已经运行了这个命令
sudo service mongod start
但是在这个命令之后,
mongod.service - High-performance, schema-free document-oriented database
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset:
Active: failed (Result: exit-code) since Thu 2017-12-21 13:35:28 IST; 6s ago
Docs: https://docs.mongodb.org/manual
Process: 4891 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (cod
Main PID: 4891 (code=exited, status=100)
I found many solution but did not get it resolved. Thanks in advance.
答案 0 :(得分:0)
确保mongod
服务在本地运行
sudo service mongod status
如果不是,请运行sudo service mongod start
如果这没有帮助,请尝试:
sudo rm /var/lib/mongodb/mongod.lock
sudo mongod --repair
再次运行service mongod start
编辑
尝试更改mongodb文件夹中的权限
cd /var/lib/mongodb
sudo chown -R mongodb:mongodb *
此外,如果这没有帮助,请运行此
sudo /usr/bin/mongod --config /etc/mongodb.conf
告诉我输出(如果它有效并不能解决你的问题,那么服务启动仍然需要修复,只是好奇)