I tried to install MongoDB as a service and it runs through even with changing the directories for log and data to D:\develop\DB\MongoDb\Server\4.2…
When I try to run mongod from the command line I always get:
exception in initAndListen: NonExistentPath: Data directory C:\data\db\ not found. Create the missing directory or specify another path using (1) the --dbpath command line option, or (2) by adding the ‘storage.dbPath’ option in the configuration file., terminating

Trying to run tghe service as a domain user results in an error dialog.

I wonder why MongoDb complains about C:}data\db.

How did you start mongod from command line?
If you just run mongod without dbpath it tries to start on default dir C:\data\db
So check if dir exists or not

1 Like

I just typed ‘mongod’ in the command line because in mongod.cfg I have:

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
dbPath: D:\develop\DB\MongoDB\Server\4.2\data
journal:
enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
destination: file
logAppend: true
path:  D:\develop\DB\MongoDB\Server\4.2\log\mongod.log

# network interfaces
net:
port: 27017
bindIp: 127.0.0.1

#processManagement:

#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:


When you are invoking mongod manually it is not using this default config file
It is looking for C:\ data\db.Since dir does not exist it is failing

The config file which you have pasted is used by default mongod which runs as service on Windows

Try to give a different port and a different path and see.It will work

@Dirk_Ulrich you need to point to the config file by using something like the following:

mongod -f c:\path\to\mongod.conf


or

mongod --config c:\path\to\mongod.conf


As @Ramachandra_Tummala states, running just mongod, the process will use the default data values.

1 Like

Both versions result in a non-responding prompt in the command line.
As you said, I installed Mongod already as a Windows service. I stopped it and tried to start mongod as you suggested but nothing happened.

This happens also when I started CMD as admin.

It is not a non responsive prompt
Most likely your mongod is up and it is expected behaviour in Windows

You have to open another cmd prompt and connect to mongod

I am trying to understand your requirement
There was no need to stop the mongod which was running as service
This is default mongod which runs on prot 27017
All you have to do is connect by issuing mongo

If you want to start another mongod you have to use different port and path
That is what i meant in my reply
You should not change the default config file

Create your own config file or you can start from command line also

mongod --port xyz --dbpath --logpath

Note:You cannot have two mongods running on same port

Please go through mongo documentation for more details

Well, I copied the original config file and renamed it from mongod.cfg to mongod.conf and changed port:

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
dbPath: D:\develop\DB\MongoDB\Server\4.2\data
journal:
enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
destination: file
logAppend: true
path:  D:\develop\DB\MongoDB\Server\4.2\log\mongod.log

# network interfaces
net:
port: 27027
bindIp: 127.0.0.1

#processManagement:

#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:


Both config files are in the same directory…but that shouldn’t cause problems, should it?
Still I have a non responding prompt.
Did I understand you right, that MongoDb uses C:\data\db as default? …how does this work with the service running properly under windows althought this directory doesn’t exist?

When it is running as service it is using default config file and using this path-D:\develop\DB\MongoDB\Server\4.2\data

Also it runs in background

But when you run it manually it looks for C:\data\db
and it runs in foreground
That’s why your session appears to be hung
So you have to open another cmd prompt and connect using mongo --port your_port

What exactly you mean by unresponsive prompt
It would have given some message

Config file can be at same location or a different location but when you start mongod give the full path and change the dirpath to new path
You changed the port but left the dbpath same as the one being used when it runs as service

Did you try a simple command line method?

mongod --dbpath your_homedir --port 28001 --logpath your_homedir/mongod.log

You can try above by config file also

mongod -f path_to_your_homedir mongod.conf
Here i am assumng your config file resides in your home dir

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.