问题描述
昨天还可以用到好好的,今天一开机连不上数据库了,新手完全不知道该怎么调试了,求指点日志如下开启mongodLast login: Sun May 7 07:59:35 on ttys001192-168-1-8:~ zuoan$ cd /Applications/Mongo/bin192-168-1-8:bin zuoan$ mongod2017-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.au2017-05-07T08:53:53.828+1000 I CONTROL [initandlisten] db version v3.4.42017-05-07T08:53:53.828+1000 I CONTROL [initandlisten] git version: 888390515874a9debd1b6c5d36559ca86b44babd2017-05-07T08:53:53.828+1000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2k 26 Jan 20172017-05-07T08:53:53.828+1000 I CONTROL [initandlisten] allocator: system2017-05-07T08:53:53.828+1000 I CONTROL [initandlisten] modules: none2017-05-07T08:53:53.828+1000 I CONTROL [initandlisten] build environment:2017-05-07T08:53:53.828+1000 I CONTROL [initandlisten] distarch: x86_642017-05-07T08:53:53.828+1000 I CONTROL [initandlisten] target_arch: x86_642017-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, terminating2017-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 exiting2017-05-07T08:53:53.831+1000 I CONTROL [initandlisten] shutting down with code:100
开启mongo192-168-1-8:bin zuoan$ mongoMongoDB shell version v3.4.4connecting to: mongodb://127.0.0.1:270172017-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 refused2017-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:6exception: connect failed
挺急的,在线求助
问题解答
回答1:应该是权限问题:
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
仔细检查 /data/db 文件夹的权限是什么。
回答2:sudo chown -R 用户名 /data/db
回答3:感觉是权限问题,我推荐你用homebrew重新装一下,我用了homebrew安装了以来就很少遇到这样的问题了。