• Register
0 votes
2.1k 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?

7.5k 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

 

38.6k points

Related questions

0 votes
1 answer 31 views
31 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 4 views
4 views
Problem: Has anyone experienced this before : Attempted to create a lock file on a read-only directory: /data/db?
asked Jun 19 Shima 126k points
0 votes
1 answer 13 views
13 views
Problem: Is there somebody who can assist: Another MongoDB instance is already running on the /data/db directory, terminating?
asked Jun 13 Nahil 128k points
0 votes
1 answer 28 views
28 views
Problem: How do I figure out about > Data directory /data/db not found., terminating ?
asked May 4 ochena 23.3k points
0 votes
1 answer 11 views
11 views
Problem: I download and install the last vesrion of MongoDb which is 4.0.2 and i set the correct path variable. When i want to start the mondoDb service using mongod command i got the following error: exception in initAndListen: NonExistentPath: Data directory C:\data\db\ ... Files\MongoDB\Server\4.0\data Now how to tell the mongo to look for the folder he thinks is missing in the correct path ?
asked Apr 26 Moumita Bhowmick 12.9k points
0 votes
1 answer 10 views
10 views
Problem: Please help me to solve it... data directory /data/db not found., terminating
asked Mar 31 Ifra 43.4k points
0 votes
1 answer 16 views
16 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 200 views
200 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.7k views
1.7k 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