Error reading from config file
I am trying to install mongodb on windows 7 64-bit. I extracted the files and copied the bin directory to c: \ mongodb. In c: \ mongodb I placed a configuration file, mongod.cfg, whose content is:
systemLog:
destination: file
path: c:\mongod\data\log\mongod.log
storage:
dbPath: c:\mongod\data\db
Then I ran the following command:
mongod.exe --config "C:\mongodb\mongod.cfg" --install
This resulted in the following error message:
error command line: unrecognized line in 'systemLog:'
I tried to save the cfg file as ANSI and UTF-8 but it didn't seem to matter. I just want mongodb to know about my storage and registration settings.
source to share
MongoDB configuration files are expressed using YAML. In YAML, a literal string can be expressed using double- quoted style , single- quoted style, or plain style (aka "unquoted").
Since your path string contains both :
and \
, you must use a single quote:
systemLog:
destination: file
path: 'c:\mongod\data\log\mongod.log'
storage:
dbPath: 'c:\mongod\data\db'
source to share
In my case it was happening because I had a version of the old db and installing the MSI installer did not update it. When I ran mongod.exe --version
it it said that I am still using the old version of db (2.2.2 for me).
I had to...
- Stop Mongo Windows support service
- Go to the Mongo download page and click on the link All versions of binaries .
- Download and extract the zip file.
- Overwrite the Mongo exe files in my installation location with the new ones from the zip.
- Remove the service with
mongod --config C:\mongodb\mongod.cfg --remove
- Install the service with
mongod --config C:\mongodb\mongod.cfg --install
I'm not sure if MSI didn't know where to install or what, but now it mongod --version
returns the correct version number error command line: unrecognized line in 'systemLog:'
when installing the service as well.
source to share
I expect this to be due to a change in storage option during the 3.0 development cycle. In some of the early release candidates, the parameter used a different case (for example, "wiredtiger"), but the canonical configuration option for final 3.0 is "wiredTiger" according to the documentation. Alternatives were supported for several consecutive point releases, but were eventually removed.
source to share