How to start a mongodb service on mac OS X?

前端 未结 10 2026
一整个雨季
一整个雨季 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:24

    Try the following steps in Terminal:

    which mongod
    

    This will output the path to your mongod, but if it is not in your $PATH the command output will be empty. So you need to find your executable:

    find / -name 'mongod'
    

    In the output of this command, you will see many lines, one of which will be like bin/mongod, e.g. /usr/local/mongodb/bin/mongod. In that case take the whole absolute path and do the following:

    echo "PATH=/usr/local/mongodb/bin/:$PATH" >> ~/.bash_profile
    . ~/.bash_profile
    

    Then try again:

    mongod --dbpath /your/path
    
    0 讨论(0)
  • 2021-01-31 03:26

    To start the mongodb, you should only have to run the "mongod" command on the terminal.

    0 讨论(0)
  • 2021-01-31 03:28

    Just do brew services start mongodb-community. Example:

    $ brew services list
    Name              Status  User Plist
    mongodb-community stopped      
    $ brew services start mongodb-community
    ==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-community)
    

    Of course, depends on your installation. This is the typical brew install.

    0 讨论(0)
  • 2021-01-31 03:28

    Try with this following steps:

    find your MongoDB path and MongoDB database path and run the below command

    /Users/username/mongodb/bin/mongod --dbpath=/Users/username/mongodb-data/
    
    0 讨论(0)
  • 2021-01-31 03:32

    Just go into a folder where you want mongodb to store all the database files and run the command

    mongod --dbpath=.

    0 讨论(0)
  • 2021-01-31 03:34

    For mongodb-community@4.2

    To start run brew services start mongodb-community@4.2

    To end run brew services stop mongodb-community@4.2

    source: Source

    0 讨论(0)
提交回复
热议问题