Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating

Tags:

mongodb

ubuntu

2019-05-21T14:25:54.799+0300 I CONTROL  [initandlisten] options: {}
2019-05-21T14:25:54.800+0300 I STORAGE  [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2019-05-21T14:25:54.800+0300 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2019-05-21T14:25:54.800+0300 I NETWORK  [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2019-05-21T14:25:54.800+0300 I CONTROL  [initandlisten] now exiting
2019-05-21T14:25:54.800+0300 I CONTROL  [initandlisten] shutting down with code:100

How do I figure out about Data directory /data/db not found., terminating

like image 548
Joshua Johns Avatar asked May 21 '19 11:05

Joshua Johns


2 Answers

I ran into this same issue a few days ago. I am using Mac OS. Apparently, there was a permission problem with having my data directory in the root of my home folder. So what i did was i just created a directory in a folder in a location where i definitely have permissions and then ran mongo db with the the --dbpath option set to that location. for example:

mongod --dbpath ~/documents/data/db

Hope this helps :D

like image 90
AnonDevs Avatar answered Oct 08 '22 03:10

AnonDevs


The problem is that by default, Mongo points to that /data/db folder, and it either forgets to create or set ownership of it on installation.

sudo mkdir -p /data/db/

And then, we’ll set the ownership of the folder to the user that’s going to start the mongod service. Since I only use if for local development in my computer, I set myself as the owner:

sudo chown `id -u` /data/db

Now, just running mongod should do the job. Hope that helps you!

like image 34
Ritik Raj Srivastava Avatar answered Oct 08 '22 05:10

Ritik Raj Srivastava