How to start a mongodb service on mac OS X?

前端 未结 10 2353
一整个雨季
一整个雨季 2021-01-31 03:02

I have already installed Mongodb on my mac but the process is currently not running. How do I start the Mongodb service so that I can start using the commands?

10条回答
  •  眼角桃花
    2021-01-31 03:34

    As now is 2021 year, so start mongodb on Mac:

    Use brew

    • brew services start mongodb-community
      • for installed by: brew install mongodb-community

    similarly:

    for specify version

    • brew services start mongodb-community@4.2
      • for installed by: brew services install mongodb-community@4.2

    only running not want bootable

    the start means start and enable start at launch/boot

    for only run currently, use run:

    • brew services run mongodb-community

    check status

    after start, check status use:

    • brew services

    Manually

    for old version mongodb, the command is mongod:

    • Directly run: mongodb
    • Run with config: mongod --config /usr/local/etc/mongod.conf
      • the default config file path is: /usr/local/etc/mongod.conf
    • Run with only pass some parameter:
      • with database path: mongod --dbpath /data
        • /data is common mongodb database path

提交回复
热议问题