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
找了两个小时,资料上说删除mongod.lock文件,,删除了之后依然没用
最后是自己重新创了一个数据库路径,并且用–dbpath命令让路径转换,才成功开启MongoDB。
rimideiMac-83:~ rimi$ cd Documents/ //随便进入一个文件夹
rimideiMac-83:Documents rimi$ mkdir mongo //创建mongo文件夹
rimideiMac-83:Documents rimi$ cd mongo //进入创建的文件夹
rimideiMac-83:mongo rimi$ mkdir db //在新创建的文件夹里面创建db文件夹
rimideiMac-83:bin rimi$ ./mongod --dbpath ~/Documents/mongo/db //运行mongod,并且使用--dbpath 定位到新创建的文件夹