The Mongod Config error

I’m having issue setting a config file pathway on windows 10. Please, I need help.

I created a new config file on “C:\tmp\config.cfg”

And I tried loading it inside vagrant terminal as. Mongod -f “c:\tmp\config.cfg”, also Mongod --config

It says error reading config file: No such file or directory.

I created a folder with full path. C:\tmp\data\db
This is my new config file:

dbpath: c:\data\db
enabled: true
destination: file
logAppend: true
path: c:\data\db\mongod.log
port: 27000
authorization: enabled

Please check your config file
Error says it is unable to read the config file
You mentioned you created C:\tmp\data\db but your config file is showing
dbpath: c:\data\db

To simplify
Just go to the dir where your config file is located and then run
mongod -f configfile
mongod --config configfile

Once in vagrant environment c: does not exist. In the Windows directory where you downloaded the setup you will find a directory named shared. This is the best place to put your config files as this directory is visible in both Windows and vagrant.

1 Like

Thanks for that info Steve,

I’ve copied my config file into the shared folder and i tried running it from the vagrant environment but still says - Error reading config file: No such file or directory.

this is the file path c:\tmp\university\m103\shared\config.txt
and c:\tmp\university\m103\shared\data\db\

Please, how do I reference it from the vagrant environment?


As Steve mentioned there is nothing like c:\ in Unix
You have to create dirs on vagrant(unix box) as mentioned in your class
And replace the paths of db directory and logfile path with Unix paths
All paths start from root dir /
vagrant@m103:~/data/db$ pwd
vagrant@m103:~/data/db$ id
uid=1000(vagrant) gid=1000(vagrant) groups=1000(vagrant)

Thanks for your response @Ramachandra_37567,

I tried following the steps you suggested but I seem more confused.

I changed the config.cfg file as follows:
dbpath: /data/db

path: /data/db/mongod.log

Then on my vagrant terminal: mongod --config mongod.cfg
and also tried: mongod --config shared/mongod.cfg

But it didn’t work.

I’ve snapped the path for you to see what I’m doing wrong.

You have to login to vagrant VM with vagrant ssh.

@James_22203 You have to run this command:
vagrant@m103:~$ mongod -f /shared/mongod.conf

I see you have the file saved as “.cfg”, I believe I used “.conf” and the config file I created and placed in the folder shared is below.

dbPath: “/data/db”

path: “/data/db/mongod.log”
destination: “file”
logAppend: true

port: 27000
bindIp: “,”

authorization: “enabled”

fork : true

After you launch “vagrant ssh”, you run the “mongod -f /shared/mongod.conf” and you should be on your way. Run the create user code in the lab after and you can validate.

Hope it works for you, cheers.

When copying yaml config file please put inside pre or code html tag to preserve indentation. The icon </> above might to the same.

Figured you already had a file in place with proper indents, sorry about that. Hope the tips helped you resolve your issue.

I do have many working config files with proper indents. My recommendation was for the others.