Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongodb 4 Data directory C:\data\db\ not found

I download and install the last vesrion of MongoDb which is 4.0.2 and i set the correct path variable.
When i want to start the mondoDb service using mongod command i got the following error:

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

i know that i should create the directory missing, but that directory is automatically created in the following path: C:\Program Files\MongoDB\Server\4.0 I checked the mongod.cfg file and the correct path is already set : dbPath: C:\Program Files\MongoDB\Server\4.0\data

Now how to tell the mongo to look for the folder he thinks is missing in the correct path ?

like image 205
Ayoub k Avatar asked Oct 04 '18 13:10

Ayoub k


3 Answers

I too had the same issue after an Windows update, Mongodb did not start automatically. Creating a new directory C:data/db will not be the right way as Mongodb has already configured the directory C:\Program Files\MongoDB\Server\4.0\data as datapath.

Run the following command in cmd as Administrator.

cd C:\Program Files\MongoDB\Server\4.0\bin
mongod --dbpath="C:\Program Files\MongoDB\Server\4.0\data".

This worked for me.

like image 140
Raja Sekar Avatar answered Oct 18 '22 05:10

Raja Sekar


I had the same issue but after I create the directory C:\data\db\ it just worked.

like image 21
Daniel Gabor Avatar answered Oct 18 '22 05:10

Daniel Gabor


i tried to open CMD in admin mode and the error was gone. Hope this helps someone.

like image 1
haidar Avatar answered Oct 18 '22 05:10

haidar