如何设置MongoDB,使其可以作为Windows服务运行?
当前回答
在Windows系统上编辑配置文件后,我不得不重新启动MongoDB (v4.4)服务。以下是我所做的:
按Win+R打开Run面板 输入“服务”。msc”,按“Enter” 搜索“MongoDB”-你可以按“m”跳转到它。 右键单击-选择“重新启动”
就是这样!
其他回答
推荐的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
如果您使用从管理员命令提示符下载的MSI安装MongoDB 2.6.1或更新版本,则会自动为您创建服务定义。
MongoDB文档也有一个教程,如果需要,可以帮助您手动创建Windows服务定义。
正在mongodb DB: 3.6上工作
(1)安装MongoDB
(2)将bin添加到环境路径变量中
(3)创建c:\data\db
(4)创建c:\data\mongo .log
(5)在bin文件夹上执行以下命令
.\mongo .exe——install——logpath c:\data\mongo .log——logappend ——bind_ip 12 7.0.0.1——dbpath c:\data\db
(6)启动mongodb作为服务
net start MongoDB
(7)最后在命令行中运行mongo,检查mongo shell是否打开。
以下是安装MongoDB as Windows Service的步骤:
Create a log directory, e.g. C:\MongoDB\log Create a db directory, e.g. C:\MongoDB\db Prepare a configuration file with following lines dbpath=C:\MongoDB\db logpath=C:\MongoDB\log Place the configuration file with name mongod.cfg in folder "C:\MongoDB\" Following command will install the Windows Service on your sc.exe create MongoDB binPath= "\"C:\MongoDB\Server\3.4\bin\mongod.exe\" --service --config=\"C:\MongoDB\mongod.cfg\" DisplayName= "MongoDB 3.4" start= "auto" Once you run this command, you will get the [SC] CreateService SUCCESS Run following command on Command Prompt net start MongoDB
在Windows系统上编辑配置文件后,我不得不重新启动MongoDB (v4.4)服务。以下是我所做的:
按Win+R打开Run面板 输入“服务”。msc”,按“Enter” 搜索“MongoDB”-你可以按“m”跳转到它。 右键单击-选择“重新启动”
就是这样!
推荐文章
- elasticsearch vs . MongoDB用于过滤应用程序
- MongoDB记录所有查询
- MongoDB:如何找到安装的MongoDB的确切版本
- 如何使用mongoimport导入CSV文件?
- 在mongodb中存储日期/时间的最佳方法
- 如何排序mongodb与pymongo
- 如何在mongodb上导入。bson文件格式
- JSON文件的蒙古导入
- 如何删除mongodb中的数组元素?
- 修改MongoDB数据存储目录
- 在MongoDB中查找重复的记录
- 为什么MongoDB Java驱动在条件中使用随机数生成器?
- 在猫鼬,我如何排序的日期?(node . js)
- 将映像存储在MongoDB数据库中
- 重复Mongo ObjectId的可能性在两个不同的集合中生成?