It worked fine yesterday, but today I can’t connect to the database when I turn it on. I’m a newbie and I don’t know how to debug it. Please give me some advice.
The log is as follows
Turn on 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: 888390515874a9debd1b6c5d36559ca86b44ba bd
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
Open 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
Very urgent, please help online
It should be a permissions issue:
Double check what the permissions are on the /data/db folder.
sudo chown -R username /data/db
It seems to be a permissions issue. I recommend you use homebrew to reinstall it. I have rarely encountered such problems since I installed it using homebrew.