大概知道问题出在哪里了。
仔细阅读了MongoDB的官方文档。文中提到:
sc.exe requires a space between “ = ” and the configuration values (i.e. binPath= `` )
所以,
sc.exe create MongoDB binPath="\"D:MongoDBServer3.6binmongod.exe\" --service --config=\"D:MongoDBServer3.6mongod.cfg\"" DisplayName="MongoDB" start= "auto"
应该写成
sc.exe create MongoDB binPath= "\"D:MongoDBServer3.6binmongod.exe\" --service --config=\"D:MongoDBServer3.6mongod.cfg\"" DisplayName= "MongoDB" start= "auto"
在bindPath=后面以及DisplayName=后面添加一个空格。
回头继续做测试!