如何设置MongoDB,使其可以作为Windows服务运行?
当前回答
请尝试Mongo DB: 3.6和Windows 10中的步骤
mongod——删除 mongod——dbpath=C:/data/db——port 27017——logpath C:/data/log/log.txt——service . dbpath=C:/data/ log/log.txt mongod——dbpath=C:/data/db——port 27017——logpath C:/data/log/log.txt——install . sh net start MongoDB
其他回答
mongod --config "C:\Program Files\MongoDB\Server\3.6\mongod_primary.cfg" --install --serviceName "MongoDB_Primary" --serviceDisplayName "MongoDB Primary"
您可以使用下面的命令将mongodb作为windows服务运行
"C:\mongodb\bin\mongod" --bind_ip yourIPadress --logpath "C:\data\dbConf\mongodb.log" --logappend --dbpath "C:\data\db" --port yourPortNumber --serviceName "YourServiceName" --serviceDisplayName "YourServiceName" --install
如果你使用mongodb默认参数,你可以使用这些值:
youripaddress: 127.0.0.1或localhost 你的portnumber: 27017(默认端口)或不放——port serviceDisplayName:仅当你运行多个服务时(从mongodb 1.8开始)
这里有关于这个命令的更多信息
http://www.mongodb.org/display/DOCS/Windows+Service
考虑使用
mongod --install --rest --master
推荐的mongod——install方法会导致错误:
2015-12-03T18:18:28.896+0100 I CONTROL --install has to be used with a log file for server output
在C:\mongodb中安装mongodb后,您需要简单地添加日志路径:
mongod --install --logpath C:\mongodb\logs\mongo.log
日志文件的路径必须存在,并且必须是Windows的绝对路径。然后你通过输入启动MongoDB服务:
net start MongoDB
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
现在一切都办好了。享受,
推荐文章
- elasticsearch vs . MongoDB用于过滤应用程序
- MongoDB记录所有查询
- MongoDB:如何找到安装的MongoDB的确切版本
- 如何使用mongoimport导入CSV文件?
- 在mongodb中存储日期/时间的最佳方法
- 如何排序mongodb与pymongo
- 如何在mongodb上导入。bson文件格式
- JSON文件的蒙古导入
- 如何删除mongodb中的数组元素?
- 修改MongoDB数据存储目录
- 在MongoDB中查找重复的记录
- 为什么MongoDB Java驱动在条件中使用随机数生成器?
- 在猫鼬,我如何排序的日期?(node . js)
- 将映像存储在MongoDB数据库中
- 重复Mongo ObjectId的可能性在两个不同的集合中生成?