Dalla riga di comando di Windows. Uso il server MongoDB 3.4 su Windows 7 Pro SP1 a 64 bit.
I collegamenti seguenti spiegano i passi:
configure-a-windows-service-for-mongodb-community-edition
manually-create-a-windows-service-for-mongodb-community-edition
La seguente riga di comando console termina MongoDB allo start-up:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Windows\System32>"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --remove
2017-12-06T08:15:47.883-0600 I CONTROL [main] Trying to remove Windows service 'MongoDB'
2017-12-06T08:15:47.884-0600 I CONTROL [main] Service 'MongoDB' removed
Il servizio MongoDB creare riga di comando (mostrato sotto) si trova nel registro di Windows qui:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\MongoDB
Per controllare, effettuare le seguenti operazioni:
C:\Windows\System32>sc.exe create MongoDB binPath= "\"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe\" --service --c
onfig=\"C:\Program Files\MongoDB\Server\3.4\mongod.cfg\"" DisplayName= "MongoDB" start= "auto"
[SC] CreateService SUCCESS
C:\Windows\System32>net start MongoDB
The MongoDB service is starting.
The MongoDB service was started successfully.
C:\Windows\System32>net stop MongoDB
The MongoDB service is stopping.
The MongoDB service was stopped successfully.
C:\Windows\System32>"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --remove
2017-12-06T08:16:36.504-0600 I CONTROL [main] Trying to remove Windows service 'MongoDB'
2017-12-06T08:16:36.505-0600 I CONTROL [main] Service 'MongoDB' removed
C:\Windows\System32>
'mongo amministratore --eval "db.shutdownServer()"' dovrebbe anche farlo. – StefanMK
Questo ha funzionato bene per me facendo manutenzione ad hoc su alcune istanze di Mongo-on-Windows. Era più affidabile dell'uso di Windows "net stop" cmd. – NateJ