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

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



Solution 1:[1]

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

Solution 2:[2]

Just create a new folder in the data directory (the disk which was given in the error - for me, suggested to create these folders on the E disk). First create data the create db folser in data. Then start mongod again.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AnonDevs
Solution 2 ouflak