• Register
0 votes

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

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
2 answers 122 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 alecxe 7.5k points
0 votes
1 answer 1.1K 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
1 vote
1 answer 291 views
Problem: Hello Pal, I have a query regarding the python programming language. The question is, which method will return an empty string when it has attempted to read beyond the end of a file? Do you have any idea about this? Thanks
asked Mar 16 Gavin 15.3k points
0 votes
1 answer 1K views
Problem : When I try to open the terminal and enter the following command: sudo mongod The output is received as below: [initandlisten] waiting for connections on port 27017 When I try to open another terminal and enter following command: sudo mongo I will open the mongo ... never posts the data. So I think my problem lies within mongo but I am unable to figure it out. POST /info 200 120002ms
asked Dec 12, 2019 alecxe 7.5k points
0 votes
1 answer 35 views
Problem: Which of the following will open a file named MyFile.txt and allow you to read data from it? a. File file = new File("MyFile.txt"); b. Scanner inputFile = new Scanner("MyFile.txt"); c. File file = new File("MyFile.txt"); Scanner inputFile = new Scanner(file); d. PrintWriter inputFile = new PrintWriter("MyFile.txt"); Does any one know correct file name?
asked Feb 22 maddi86 5.4k points