mongodb报错1: connecting to:mongodb://127.0.0.1:27017. connect failed

执行mongo,报错如下:

./mongo
MongoDB shell version v4.0.0
connecting to: mongodb://127.0.0.1:27017
2018-07-30T14:24:00.807+0800 E QUERY    [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:251:13
@(connect):1:6
exception: connect failed

是没有执行mongod,就直接执行mongo,才会报错

操作:

sudo ./mongod  -dbpath /data/db/

./mongo 
#都在mongodb的bin目录下

不知道/data/db是啥:https://blog.csdn.net/qq_39729527/article/details/81285072

你可能感兴趣的:(数据库,Exception)