mac环境中mongodb启动失败:
rimideiMac-83:bin rimi$ ./mongo MongoDB shell version v3.6.9 connecting to: mongodb://127.0.0.1:27017 2018-11-22T18:34:17.494+0800 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused 2018-11-22T18:34:17.499+0800 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed : connect@src/mongo/shell/mongo.js:257:13 @(connect):1:6 exception: connect failed
解决方法:
1、随便进入一个文件夹
2、用mkdir创建mongo文件夹
3、用cd进入创建的文件夹
4、用mkdir在新创建的文件夹里面创建db文件夹
5、运行mongod,并且使用——dbpath,定位到新创建的文件夹
rimideiMac-83:~ rimi$ cd Documents rimideiMac-83:Documents rimi$ mkdir mongo rimideiMac-83:Documents rimi$ cd mongo rimideiMac-83:mongo rimi$ mkdir db rimideiMac-83:bin rimi$ ./mongod --dbpath ~/Documents/mongo/db