English 中文(简体)
如何在Windows上停电网服务器?
原标题:How to stop mongodb server on Windows?

I m using the nginx/PHP/MongoDB stack and trying to set up my development environment on Windows by creating two batch files.

开始。

cd C:www
ginx
start nginx
cd C:wwwphp
start php-cgi.exe -b 127.0.0.1:9000
cd C:wwwmongodb
start mongod

停下来。

cd C:www
ginx
nginx -s quit
cd C:wwwphp
taskkill /F /IM php-cgi.exe
cd C:wwwmongodb
mongo --eval "use admin; db.shutdownServer(); quit"  # this doesn t work
mongo --eval stop_mongod.js  # this doesn t work either

Using taskkill to stop mongod isn t an option, since that may lead to data corruption. Any suggestions?

最佳回答

From the mongo shell documentation:


简称

这一指挥没有按规定行事。 相反,你们需要明确界定相关数据库(如上所示)。

Alternately, you can also create a connection within the script:

db2 = connect("server:27017/otherdbname")

I ve come up with the following code: Save the following snippet in stop_mongod.js file:

 db = connect("localhost:27017/admin");
 db.shutdownServer();
 quit();

如有必要,调整联系。 之后,从指挥线或从你的手稿中:

mongo stop_mongod.js
问题回答

我不敢肯定,这样做的恰当方式,发射杀人行为可能给贵的蒙戈服务器造成破坏,你在坠毁后需要修理你的数据库。

或许你们已经解决了这一问题,但这里是我做的:

mongo admin --eval "db.shutdownServer()"

我马上在行政收集上自动连接,然后,我就不得不放弃。

http://api.mongodb.org/wiki/present/start%20and%20Stopping%20Mongo.html”rel=“noreferer” http://api.mongodb.org/wiki/ 当前/start%20and%20Stopping%20Mongo.html

Best

  1. 开放指挥部(Prompt/Powershell)担任署长。

  2. Execute

    净额

即时指挥

net stop mongodb

If the server is running as the foreground process in a terminal, this can be done by pressing

Ctrl-C

清理运行服务器的另一个办法是使用关闭指挥系统,

> use admin
> db.shutdownServer();

如果你把mongodb安装在窗户上。 您可以在上级指挥下迅速停止服役。

 net stop mongodb

I guess, using TASKKILL /IM mongod. 可耻地终止电网服务。





相关问题
Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question. The answer was because it has powerful access to local resources, and Network Service ...

Programmatically detect Windows cluster configuration?

Does anyone know how to programatically detect that a Windows server is part of a cluster? Further, is it possible to detect that the server is the active or passive node? [Edit] And detect it from ...

get file icon for Outlook appointment (.msg)

I ve read Get File Icon used by Shell and the other similar posts - and already use SHFileInfo to get the associated icon for any given extension, and that works great. However, Outlook uses ".msg" ...

Identifying idle state on a windows machine

I know about the GetLastInputInfo method but that would only give me the duration since last user input - keyboard or mouse. If a user input was last received 10 minutes ago, that wouldn t mean the ...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...

热门标签