Configuration File MongoDB 4.4 Communuty Server

To get the default Configuration File of MongoDB Windows MSI Installer \bin\mongod.cfg.
My install directory is C:\Program Files\MongoDB\4.4\Server.
To configure mongod or mongos using a configuration file , we can specify – config option as follows:

mongod --config which is mongod --config C:\Program Files\MongoDB\Server\4.4\bin\mongod.cfg in my installation directory.

mongos --config
which is mongos --config C:\Program Files\MongoDB\Server\4.4\bin\mongod.cfg in my installation directory.
In the both cases, while configuring both mongod and mongos , I am getting error.
Please look into it.
Arindam Biswas.

What error are you getting
Please show us the error or screenshot

While installing did you install mongod as service or just binaries installed?


Install MongoD as a Service
In response to your query , I hereby attach the following screen shots.
(1) Errors while configuring mongod ( mongos not shown here) from the Command Prompt.
(2) Installation of mongod as a service.

Why do you want to start mongod if it is installed as service
It may be already up and running on default port 27017
Just issue mongo
If you can connect means it is up
or you can check from Windows services

If you want to start another/your own mongod prepare your own config file giving different values for dbpath,logpath,port etc

Your first command is correct but failed to start mongod as you are using default config file but that may be already being used by mongod which started as service
So it is not able to create logfile and exiting with error

So, when once Windows services is installed, there is no need to use this command line option of this configuration files. We can use it only before installation.
My mongo installation is ok. Please see the screen shot.

Yes as far as default mongod is concerned you don’t have to do anything
Just connect to mongo and run few commands
db
show dbs

Create collection or load data and explore other commands

If you want additional mongod on same box (for testing or any other purpose) create your config file and you can start it with config file or command line parameters

ex: mongod --port 28000 -dbpath your_home_dir --logpath your_home_dir
Check mongo documentation for various options like auth etc

While I am transferring data of my mongod log file to my own directory C:\data\log , I am getting the following error : " The process can not access the file because it is being used by other process" .

While I am transferring data from my MongoDB data file to my own directory C:\data\db , it is ok and data is being transferred to my directory C:\data\db.

In the first case , I use the following command in the command prompt
“C:\Program Files\MongoDB\Server\4.4\log\mongod.log” --logpath “C\data\log”

In the second case, I use the following command in the command prompt “C:\Program Files\MongoDB\Server\4.4\bin\mongod.exe” --dbpath "C:\data\db

Also, while I try to configure mongod log file in different port (port :2800 ) usuing the following command, I get an error.
mongod --port 2800 --logpath C:\data\log

I find ok when I configure mongod data file in different port (port : 2800) by the following command.
mongod --port 2800 --dbpath C:\data\db


Please find the relevant screen shots.

Your screenshots not matching with the description you mentioned about the errors while starting mongod on port 2800
It is 28000 not 2800

In the first snapshot you did not run mongod but tried to set logpath with mongod.log which is invalid command
Second snapshot appears to be from earlier post which i have already explained why it is failing
When your default mongod is already up and running why you are trying to run mongod again with default config file
Please do not touch default cfg file nor use it to run another mongod.It is kind of master file
I clearly told you to prepare your own config file under different directory using master file as reference
Something like below
mongod --config “C:\Users\xyz\my_cfg.cfg”
You have to create the file my_cfg.cfg and add different parameters then save it
Also you seem to run same mongod command multiple times to set different parameters
It will not work that way
All necessary parameters should be passed in the command line in single attempt
Example:
mongod --port 28000 --dbpath your_db_path --logpath your_logpath
When you start mongod on a different port you have to connect specifying port num
mongo --port 28000

I suggest you review mongo documentation
It will be confusing initially but will be clear as you go forward

1 Like

Please note that I am unable to create my own config file under my own directory. Screen shot enclosed.

mongod is expecting a file my_cfg.cfg but you created a directory
Go to C:\Users\arindam1 open a text editor like notepad.Add required parameters.Save the file
It has to follow YAML format else you will get errors
Then run the mongod command again.It should work

Thank you for your advice. Sorry, for replying in late. I am going through the YAML standard. I take time to be conversant in writing parameters in YAML format.
As we add more parameters in YAML standard , we shall get additional features of MongoDB instances. I am just trying to experiment on it. I may turn up again if I face issues while I shall be experimenting on additional features on MongoDB instances.