我在Windows 10上将Mongodb最新版本(4.0)安装为服务 似乎它忽略了bin目录中的mongod.cfg文件
C:\MongoDB4.0\bin\mongod.cfg
# Where and how to store data.
storage:
dbPath: C:\MongoDB4.0\data
服务将无法启动,
当我从CMD启动它时:
c:\MongoDB4.0\bin>mongod.exe
这是它的输出:(请参阅dbpath = c:\ data \ db)
Log: [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
Log: [initandlisten] MongoDB starting : pid=7104 port=27017 dbpath=c:\data\db\ 64-bit host=Win10-Pc
Log: [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
Log: [initandlisten] db version v4.0.2
Log: [initandlisten] git version: fc1573ba18aee42f97a3bb13b67af7d837826b47
我看到该服务将配置作为参数
C:\ MongoDB4.0 \ bin \ mongod.exe --config“ C:\ MongoDB4.0 \ bin \ mongod.cfg”-服务
答案 0 :(得分:2)
The --service
option is used to create the initial service definition, and should generally not be required if you are using a MongoDB 4.0+ installer (which includes this step during installation).
To manage the MongoDB service from the command line you need to use net start MongoDB
and net stop MongoDB
.
c:\MongoDB4.0\bin>mongod.exe
If you run mongod.exe
without any parameters the default values will be used (such as c:\data\db
for the dbPath
). The server binary does not currently have a default location for a configuration file.
There's a relevant feature request to watch/upvote in the MongoDB issue tracker: SERVER-36150: Improved Default Config File Handling.