Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error reading from configuration file

Tags:

mongodb

I'm trying to install mongodb on windows 7 64-bit. I've extracted the files and copied the bin directory to c:\mongodb. Under c:\mongodb I've 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

I then ran the following command:

mongod.exe --config "C:\mongodb\mongod.cfg" --install

The result was the following error message:

error command line: unrecognized line in 'systemLog:'

I tried to save the cfg file as both ANSI and UTF-8 but it didn't seem to matter. I just want mongodb to be aware of my storage and log settings.

like image 801
Mister_L Avatar asked Apr 25 '26 14:04

Mister_L


2 Answers

MongoDB configuration files are expressed using YAML. In YAML, litteral string can be expressed using double-quoted style, single-quoted style or plain style (aka "unquoted").

As your path string contains both : and \ you have to use single-quoted style here:

systemLog:
   destination: file
   path: 'c:\mongod\data\log\mongod.log'
storage:
   dbPath: 'c:\mongod\data\db'
like image 177
Sylvain Leroux Avatar answered Apr 28 '26 03:04

Sylvain Leroux


In my case this was happening because I had an old db version running and installing the MSI installer didn't upgrade it. When I ran mongod.exe --version, it said I was still running an old db version (2.2.2 for me).

I had to...

  1. Stop the Mongo Windows Service
  2. Go to the Mongo Download Center page, and click on the All Version Binaries link.
  3. Download and extract the zip file.
  4. Overwrite the Mongo exe files in my install location with the new ones from the zip.
  5. Remove the service with mongod --config C:\mongodb\mongod.cfg --remove
  6. Install the service with mongod --config C:\mongodb\mongod.cfg --install

I'm not sure if the MSI didn't know where to install or what, but now mongod --version returns the proper version number, and no error command line: unrecognized line in 'systemLog:' when installing the service.

like image 38
racingcow Avatar answered Apr 28 '26 05:04

racingcow