如何设置MongoDB,使其可以作为Windows服务运行?
当前回答
check windows services if you have service for mongo remove it by run bellow command mongod --remove create mongo.cfg file with bellow content systemLog: destination: file path: c:\data\log\mongod.log storage: dbPath: c:\data\db path: where you want to store log datas dbPath: your database directory then run bellow command sc.exe create MongoDB binPath= "\"C:\Program Files\MongoDB\Server\3.2\bin\mongod.exe\" --service --config=\"C:\Program Files\MongoDB\Server\3.2\mongod.cfg\"" DisplayName= "MongoDB" start= "auto" binPath : mongodb installation directory config: .cfg file address DisplayName:Your Service Name start service net start MongoDB
现在一切都办好了。享受,
其他回答
mongod --config "C:\Program Files\MongoDB\Server\3.6\mongod_primary.cfg" --install --serviceName "MongoDB_Primary" --serviceDisplayName "MongoDB Primary"
这是唯一对我有用的方法。因为所有东西都必须是绝对路径:
C:\Program Files\MongoDB\Server\3.2\bin>mongod --install --dbpath=c:/data/db --logpath=c:/data/logs/log.txt
我还必须从管理cmd运行它
在Windows系统上编辑配置文件后,我不得不重新启动MongoDB (v4.4)服务。以下是我所做的:
按Win+R打开Run面板 输入“服务”。msc”,按“Enter” 搜索“MongoDB”-你可以按“m”跳转到它。 右键单击-选择“重新启动”
就是这样!
不仅——安装,
还需要——dbpath和——logpath
重启操作系统后,你需要删除“mongod”。手动锁”
这对我来说很管用:
sc.exe create MongoDB binPath= "d:\MongoDB\bin\mongod.exe --service --config=d:\MongoDB\bin\mongod.config" displayname= "MongoDB 2.6 Standard" start= "auto"
逃脱binPath是失败的我在Mongo文档中描述
失败:
sc.exe create MongoDB binPath= "\"C:\Program Files\MongoDB 2.6 Standard\bin\mongod.exe\" --service --config=\"C:\Program Files\MongoDB 2.6 Standard\mongod.cfg\"" DisplayName= "MongoDB 2.6 Standard" start= "auto"
推荐文章
- 无法连接到服务器127.0.0.1:27017
- 如何创建数据库的MongoDB转储?
- 如何将MongoDB作为Windows服务运行?
- 如何监听MongoDB集合的变化?
- 什么时候不使用Cassandra?
- 如何在猫鼬排序?
- BASE术语解释
- .msi和setup.exe文件之间的具体区别是什么?
- 映射一个网络驱动器供服务使用
- js的Mongoose.js字符串到ObjectId函数
- 如何从java应用程序创建一个windows服务
- mongodb中使用ISODate的日期查询似乎无法正常工作
- 如何更新文档数组中的对象(嵌套更新)
- 在猫鼬模式中添加created_at和updated_at字段
- 如何更新mongodb中的多个数组元素