昨天还可以用到好好的,今天一开机连不上数据库了,新手完全不知道该怎么调试了,求指点
日志如下
开启mongod
Last login: Sun May 7 07:59:35 on ttys001
192-168-1-8:~ zuoan$ cd /Applications/Mongo/bin
192-168-1-8:bin zuoan$ mongod
2017-05-07T08:53:53.828+1000 I CONTROL [initandlisten] MongoDB starting : pid=1802 port=27017 dbpath=/data/db 64-bit host=192-168-1-8.tpgi.com.au
2017-05-07T08:53:53.828+1000 I CONTROL [initandlisten] db version v3.4.4
2017-05-07T08:53:53.828+1000 I CONTROL [initandlisten] git version: 888390515874a9debd1b6c5d36559ca86b44babd
2017-05-07T08:53:53.828+1000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2k 26 Jan 2017
2017-05-07T08:53:53.828+1000 I CONTROL [initandlisten] allocator: system
2017-05-07T08:53:53.828+1000 I CONTROL [initandlisten] modules: none
2017-05-07T08:53:53.828+1000 I CONTROL [initandlisten] build environment:
2017-05-07T08:53:53.828+1000 I CONTROL [initandlisten] distarch: x86_64
2017-05-07T08:53:53.828+1000 I CONTROL [initandlisten] target_arch: x86_64
2017-05-07T08:53:53.828+1000 I CONTROL [initandlisten] options: {}
2017-05-07T08:53:53.830+1000 I STORAGE [initandlisten] exception in initAndListen: 20 Attempted to create a lock file on a read-only directory: /data/db, terminating
2017-05-07T08:53:53.830+1000 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-05-07T08:53:53.830+1000 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-05-07T08:53:53.831+1000 I CONTROL [initandlisten] now exiting
2017-05-07T08:53:53.831+1000 I CONTROL [initandlisten] shutting down with code:100
开启mongo
192-168-1-8:bin zuoan$ mongo
MongoDB shell version v3.4.4
connecting to: mongodb://127.0.0.1:27017
2017-05-07T08:54:05.079+1000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2017-05-07T08:54:05.080+1000 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
挺急的,在线求助
应该是权限问题:
仔细检查 /data/db 文件夹的权限是什么。
sudo chown -R 用户名 /data/db
感觉是权限问题,我推荐你用homebrew重新装一下,我用了homebrew安装了以来就很少遇到这样的问题了。