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

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
2 answers 147 views
147 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.3K views
1.3K 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 683 views
683 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, 2020 Gavin 15.3k points
0 votes
1 answer 1.7K views
1.7K 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
1 vote
1 answer 233 views
233 views
Problem : I am very new to Node.js. I want to create a small application which uses the express and mongosse to store some of the users in my based cloud database i.e. mongoDB via mlab. Please find below MyUser.js (models/MyUser.js) var dbmongoose = require('mongoose'); ... hard from past few days to fix above error but I am still unable to fix it. I am looking for expert help to fix above error.
asked Apr 8, 2020 morrisBson 3.2k points
0 votes
1 answer 1K views
1K views
Problem : I want Import the dummy JSON file into my MongoDB but facing below error. I am unable to understand the below error and so can not find the suitable "simple English" explanation nowhere to understand it by myself, so if you have any solution ... mongoimport --jsonArray --collection some_data --file /path/path/data.json $ mongoimport --jsonArray --collection some_data /path/path/data.json
asked Dec 19, 2019 alecxe 7.5k points
0 votes
1 answer 73 views
73 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, 2020 maddi86 5.4k points
0 votes
1 answer 403 views
403 views
Problem : I am trying to do the file upload & enter the data task into my MongoDB using a flask but I had below error when I filled my form & upload my image: “Bad Request The browser (or proxy) sent a request that this server could ... mypassword, 'email': myemail, 'img_name': file_name})         return render_template('index.html')     else:         return render_template('index.html')
asked Jan 22, 2020 jwilliam 3.9k points
0 votes
1 answer 54 views
54 views
Problem: I am the beginner to MongoDB. I had followed all the steps which are mention in MongoDB installation documents for the Ubuntu 16.04. I executed the following command: sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv ... when I started my MongoDB then encountered an error as below: Failed to start mongod.service: Unit mongod.service not found.
asked Jul 29, 2020 Raphael Pacheco 4.9k points
2 votes
1 answer 428 views
428 views
Problem : I am very new to Mongodb, I am facing below error if I try to run the Mongodb. I had installed it with the help of Homebrew. Stewarts-MacBook-Pro:~ stewart$ mongod 2020-05-05T15:31:15.911+0700 I CONTROL  [initandlisten] MongoDB starting : pid ... +0700 I CONTROL  [initandlisten] shutting down with code:48 Stewarts -MacBook-Pro:~ stewart $ Kindly help me in resolving above Mongodb error.
asked May 6, 2020 stewart 4k points