简体   繁体   中英

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

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

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!

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.

"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM