mongodb错误.我如何解决mongoDB中的错误?

moh*_*ith 5 ubuntu mongodb ubuntu-16.04

MongoDB shell版本:3.2.6连接到:test

2016-05-08T10:46:12.023+0530 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2016-05-08T10:46:12.023+0530 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:229:14
@(connect):1:6

exception: connect failed
Run Code Online (Sandbox Code Playgroud)

https://docs.mongodb.com/v3.0/tutorial/install-mongodb-on-ubuntu/

Rav*_*ezu 9

你有mongodb服务吗?运行sudo service mongod status并查看它返回的内容.如果它已停止,请运行sudo service mongod start以启动mongodb并尝试连接到它.

您也可以通过运行:来检查mongodb是否正在侦听27017 sudo netstat -lnp | grep 27017.

如果sudo service mongod start给出错误,您可能需要检查配置.如果您可以发布上述命令的输出,我们可以更好地帮助您.

更新:

/etc/systemd/system/mongod.service使用以下内容创建文件:

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)