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.
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
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.
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