windows下启动mongodb为后台进程加fork选项报错如下:
D:\Program Files\MongoDB\Server\3.2\bin>mongod --config "D:\Program Files\MongoD
B\Server\mongodb.conf"Error parsing INI config file: unrecognised option 'fork'
try 'mongod --help' for more information
原因:
--fork不支持windows 解决可以通过添加mongodb为windows服务来解决
如下:
The command --fork only works for Linux/Unix. If you need --fork for running mongod in background, on Windows that can be achieved by installing mongod as a service.When use mongod --install option to install mongodb service, the --dbpath and --logpath are required. In my case, I need use administrator command console to install the service.
For example:
mongod --dbpath=C:\mongodb\data --logpath=C:\mongodb\data\log\service.log --install
Then browse the log file to see service name and other information including any possible errors.
2014-06-25T18:21:14.245-0700 Trying to install Windows service 'MongoDB'
2014-06-25T18:21:14.253-0700 Service 'MongoDB' (MongoDB) installed with command line 'C:\mongodb-win32-x86_64-2008plus-2.6.1\bin\mongod.exe --dbpath=C:\mongodb\data --logpath=C:\mongodb\data\log\service.log --service'
2014-06-25T18:21:14.254-0700 Service can be started from the command line with 'net start MongoDB'
The default service name is "MongoDB". You can name the service name with --serviceName option when install the service.
Then start the service with net use.
net use MongoDB