报错信息如下:
[root@166 bin]# mongo
MongoDB shell version v3.4.6-22-ga109a23
connecting to: mongodb://127.0.0.1:27017
2017-10-16T10:57:28.624+0800 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2017-10-16T10:57:28.625+0800 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:237:13
@(connect):1:6
exception: connect failed
解决办法:
1.进入/data/db目录下,删除mongo.lock文件
2.进入/mongodb/bin目录下,执行 ./mongod
3.重新开个窗口,执行 ./mongo --dbpath=/data/platform/mongoDB/data/db/
启动时注意后面加上db路径,否则启动失败。还需要考虑权限问题。
4.至此 启动成功