MongoDB DBA · Question 134 · Single choice

18. Which of the following choices is the preferred method for stopping a running mongod process from the command line? Assume mongod was run without the --fork flag. Choose the best answer:

Answer options

  1. A.
    running killall mongod or taskkill mongod from the terminal
  2. B.
    running db.shutdownServer() from the mongo shell
  3. C.
    pushing ctrl + break or ctrl + c from the terminal where mongod is running
  4. D.
    running db.dropDatabase() from the mongo shell
  5. E.
    closing the terminal the mongod is running in

Answer confidence: High

Correct answer: B

Explanation language: Chinese

未使用 --fork 时,推荐在 mongo shell 里执行 db.shutdownServer()(即 admin 库的 shutdown 命令),它会让 mongod 干净地刷盘并退出。killall、关终端、ctrl+c 都属于强制或非正常终止,dropDatabase 只是删库,都不是停服手段。

Papers containing this question

This question appears in 3 bank records. Public pages combine identical prompts and options. Selected questions display the highest-confidence record; the others show a short preview. Paper-based learning preserves each record's answer, explanation, and confidence.

AUTHOR · PROJECTS · OPEN SOURCE

Author & MongoDB projects

Building data platforms, MongoDB migration and sync tools, and cloud operations products.

Contact the author for any MongoDB needs.

Contact the author ↗mlhp123@outlook.com

Support the author

If this question bank helps you, optional donations are welcome.

Scan with Alipay to support the authorOpen full-size donation image ↗