[英]Setting up Mongodb on Windows
I am trying to get starting with Mongodb. 我正在尝试开始使用Mongodb。 I installed it and moved the installation directory to my xampp directory.
我安装了它,并将安装目录移到我的xampp目录。 I would like to start developing using Mongodb, is the
mongod.exe
service required to run, in order to write code that uses mongodb ? 我想开始使用Mongodb进行开发,是否需要运行
mongod.exe
服务才能编写使用mongodb的代码?
I am able to connect to this service successfully, however once I disconnect from the mongod.exe
service and try to run mongo.exe
I get an error saying No connection could be made because the target machine actively refused it
. 我能够成功连接到该服务,但是一旦我断开与
mongod.exe
服务的连接并尝试运行mongo.exe
我会收到一条错误消息,提示No connection could be made because the target machine actively refused it
。 I am running cmd
as administrator. 我以管理员身份运行
cmd
。 However, when I run the mongod.exe
service first, then try to run the mongo.exe
, I am able to connect successfully. 但是,当我先运行
mongod.exe
服务,然后尝试运行mongo.exe
,我能够成功连接。
My question is, if I am developing on Windows using xampp, am I supposed to run the mongod
service prior to writing code to query the DB ? 我的问题是,如果我正在使用xampp在Windows上进行开发,是否应该在编写代码以查询数据库之前运行
mongod
服务?
Thanks in advance. 提前致谢。
Yes , the mongod.exe(server) needs to be running if you want to read/write data to MongoDB. 是的,如果要向MongoDB读取/写入数据,则mongod.exe(server)需要运行。 mongo.exe is a shell which checks if the server(mongod.exe) is running if 'yes' then it allows to read/write data to MongoDB.
mongo.exe是一个外壳程序,用于检查服务器(mongod.exe)是否正在运行(如果是),则它允许向MongoDB读取/写入数据。 Hence prior to querying the DB you need to bring up mongod.exe
因此,在查询数据库之前,您需要启动mongod.exe
I recommend you leave the default directory mongodb in "C: \\ DATA \\ DB \\ bin" and install mongo as a service to start with windows with the code in CMD: 我建议您将默认目录mongodb保留在“ C:\\ DATA \\ DB \\ bin”中,并将mongo作为服务安装,以Windows开头的CMD代码:
C:\\DATA\\DB\\bin>mongod --dbpath=C:\\DATA\\DB\\bin\\mongod.exe --logpath=D:\\mongodb\\log.txt --install C:\\ DATA \\ DB \\ bin> mongod --dbpath = C:\\ DATA \\ DB \\ bin \\ mongod.exe --logpath = D:\\ mongodb \\ log.txt --install
configure the service to start automatically and you will not need to worry about it. 将服务配置为自动启动,您无需担心。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.