How to stop mongo DB in one command

前端 未结 18 1245
小蘑菇
小蘑菇 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:38

    If you literally want a one line equivalent to the commands in your original question, you could alias:

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

    Mark's answer on starting and stopping MongoDB via services is the more typical (and recommended) administrative approach.

提交回复
热议问题