How to stop mongo DB in one command

前端 未结 18 1224
小蘑菇
小蘑菇 2020-12-04 05:21

I need to be able to start/stop MongoDB on the cli. It is quite simple to start:

./mongod

But to stop mongo DB, I need to run open m

18条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-04 05:31

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

    Ctrl-C
    

    Another way to cleanly shut down a running server is to use the shutdown command,

    > use admin
    > db.shutdownServer();
    

    Otherwise, a command like kill can be used to send the signal. If mongod has 10014 as its PID, the command would be

    kill -2 10014
    

提交回复
热议问题