mongodb Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :

mongodb启动报错:
MongoDB shell version: 3.2.20
connecting to: test
2018-08-10T19:26:24.102+0800 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused
2018-08-10T19:26:24.103+0800 E QUERY [thread1] Error: couldn’t connect to server 127.0.0.1:27017, connection attempt failed :
[email protected]/mongo/shell/mongo.js:229:14
@(connect):1:6

exception: connect failed

网上找了很多办法都没有解决,自己找到了一个解决办法,如下:、
mongodb Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
mongodb Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :

这里说 exception in initAndListen: 29 Data directory /data/db not found., terminating
mongodb Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :

我们自己创建文件夹,并更改权限,再次测试可以使用

mongodb Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :