我一直在尝试安装Mongodb,但是它一直在中途失败。下载完成后,安装失败并出现连接错误:
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
2018-08-17T12:26:33.340+0200 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2018-08-17T12:26:33.340+0200 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:251:13
@(connect):1:6
exception: connect failed
我尝试过的方法:
1.更改端口:
mongo --port 4332
但它仍然无法连接:
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:4332/
2018-08-17T12:32:55.743+0200 W NETWORK [thread1] Failed to connect to 127.0.0.1:4332, in(checking socket for error after poll), reason: Connection refused
2018-08-17T12:32:55.743+0200 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:4332, connection attempt failed :
connect@src/mongo/shell/mongo.js:251:13
@(connect):1:6
exception: connect failed
/etc/mongo*
或/var/lib/
中是否有任何配置文件:没有。答案 0 :(得分:1)
安装似乎已经成功,但是mongod尚未启动。
MongoDB需要两个元素:
“ mongo” shell实用程序,用于直接连接到数据库 真正的数据库程序是“ mongod”服务。
要启动mongod,只需使用cmd并使用“ mongod”命令即可。如果:
,此命令可能会失败Fedora存储库不能同时安装两者。 该外壳位于存储库中,名称为“ mongodb” 服务器的名称为“ mongodb-server”
要同时安装两者,您需要做
dnf install mongodb mongodb-server
然后您可以使用
启动mongod服务sudo service mongod start