• Register
0 votes
1.4k views

Problem :

I had created /data/db in my root directory and ran ./mongod but getting below error :

 

[initandlisten] exception in initAndListen: 20 Attempted to create a lock file on a read-only directory: /data/db, terminating
[initandlisten] shutdown: going to close listening sockets...
[initandlisten] shutdown: going to flush diaglog...
[initandlisten] now exiting
[initandlisten] shutting down with code:100

 

Have anybody faced above error? any clues to fix above error?

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

The problem is that your directory which you created, /data/db is owned by the root and only writable by your root user, and you are trying to run mongod as yourself. There are many ways to solve your issue, but ultimately, you should give your directory in question the correct permissions. If this is for the production, then I must advise you to check your docs and think again on it very carefully, you may want to take the special care.

But if this is just for the testing purpose and you just need to do this to work and get on with it, then you must try below command, which will make your directory writable by everyone:

> sudo chmod -R go+w /data/db

Or below command, which will make your directory owned by you:

> sudo chown -R $USER /data/db

 

9 7 4
38,600 points

Related questions

0 votes
1 answer 8 views
8 views
Problem: Have anybody faced this error? any clues to fix this error: Attempted to create a lock file on a read-only directory: /data/db, terminating
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
1 answer 2 views
2 views
Problem: Please help me to solve it... data directory /data/db not found., terminating
asked Mar 31 Ifra 24.4k points
0 votes
1 answer 8 views
8 views
Problem: I got following message : exception in initandlisten: nonexistentpath: data directory /data/db not found., terminating Any help!!
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
2 answers 161 views
161 views
Problem : When I was trying to run the Mongod in terminal I got below message : 2020-01-14T17:33:04.554+0700 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating 2020-01-14T17:33:04.554+0700 I CONTROL [initandlisten] dbexit ... src/mongo/shell/mongo.js:179 exception: connect failed I am using the Ubuntu 14.04 LTS 64 bit. How can I fix this issue?
asked Jan 10, 2020 alecxe 7.5k points
0 votes
1 answer 1.5K views
1.5K views
Problem : When I tried to run Mongodb in terminal I got following message : exception in initandlisten: nonexistentpath: data directory /data/db not found., terminating
asked Nov 15, 2019 peterlaw 6.9k points
0 votes
1 answer 4 views
4 views
Problem: Can any one tell me about that why i am unable to lock directory /var/cache/apt/archives/?
asked Mar 18 waseem memon 2.4k points
0 votes
1 answer 3 views
3 views
Problem: I have an problem that i am unable to lock the administration directory. anyone have answer of this problem??
asked Mar 18 waseem memon 2.4k points
0 votes
1 answer 3 views
3 views
Problem: i have an issue that i am unable to lock the administration directory (/var/lib/dpkg/), are you root?
asked Mar 18 waseem memon 2.4k points
0 votes
1 answer 2 views
2 views
Problem: Please help me fix this dilemma: could not open lock file /var/lib/dpkg/lock.
asked 6 days ago tuhin1 48.4k points