Programmers learn & share
0 votes
720 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
by (6.9k points)   | 720 views

1 Answer

0 votes

Solution :

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

 /data/db

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.

by (36.1k points)  
my mongod.conf says:  dbPath: /var/lib/mongodb

so, why is it still looking for /data/db ?
2,245 questions
2,807 answers
60 comments
241 users