• Register
0 votes

Problem :

When I tried to run Mongodb in terminal I got following message :
exception in initandlisten: nonexistentpath: data directory /data/db not found., terminating
6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

Please note MongoDB needs data directory to store data. Default path is as follows:


When you try to start MongoDB engine it generaly searches this directory which must be missing in your case. So the smple Solution is to create this directory and assign the rwx permission to user.

If you want to update the path of your data directory then you must specify it while starting mongod server like as follows

mongod --dbpath /data/<path> --port <port no> 

This change will help you to start your mongod server with custom path and port.

9 7 4
38,600 points
my mongod.conf says:  dbPath: /var/lib/mongodb

so, why is it still looking for /data/db ?

Related questions

0 votes
2 answers 155 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.2K 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 ... .. [initandlisten] now exiting [initandlisten] shutting down with code:100 Have anybody faced above error? any clues to fix above error?
asked Jan 4, 2020 alecxe 7.5k points
0 votes
1 answer 5 views
Problem: failed: error connecting to db server: no reachable servers.
asked Feb 16 charles mathews 3.8k points
0 votes
1 answer 88 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
0 votes
1 answer 18 views
Problem Hi Kodlogs, I am getting following error on my Linux: sudo apt-get command not found How do I fix this?
asked Nov 3, 2020 hashq 1.1k points
0 votes
1 answer 95 views
I'm a newbie when it comes to Linux administration using bash... I was following a tutorial on how to install laravel 5.2 from here... installed it successfully... firstly I installed composer and ran the following command composer global require "laravel/installer" after this put ... the path Note: I have installed oh my zsh on my terminal... What do I have to do to get it working please help
asked Sep 13, 2020 Marivoke 530 points
1 vote
1 answer 18 views
Problem: Hello Kodlogs, I am a Linux user and currently running Ubuntu 18.04 LTS distribution on my machine. I&rsquo;ve written a sample python program and trying to execute it through the Linux terminal. My sample program is saved as samle.py and I put a command ... command not found Why this is happening? Could you please give a hint? How could I overcome the error? Thanks for enlightening me.
asked Aug 1, 2020 adamSw 11.3k points
0 votes
1 answer 29 views
Problem How to count number of files in a directory on Linux?
asked Oct 31, 2020 hashq 1.1k points
1 vote
1 answer 52 views
Problem: I want to install one package named speech_tools-2.1-release.tar.gz. After I run the command ./configure in this package, it shows me a message:\ Configure: error: no acceptable C compiler found in $PATH See 'config.log' for more details Any solution would be much appreciated. Thanks.
asked Mar 10, 2020 Gavin 15.3k points