MongoDB installed via Homebrew not working

前端 未结 5 847
迷失自我
迷失自我 2021-02-19 21:55

I installed MongoDB via Homebrew (following http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/) but it\'s not working.

Typing mongod at shell

相关标签:
5条回答
  • 2021-02-19 22:22

    Copied from a different channel running these commands in the terminal updated the installation/configuration issues as described in OP

    brew tap mongodb/brew
    brew install mongodb-community
    brew services start mongodb-community
    
    0 讨论(0)
  • 2021-02-19 22:28

    You're getting this error because your 'brew' install failed to create the correct symlinks in /usr/local/bin. As a result, the shell can't find the mongo executables in your $PATH. You can fix this using the following steps:

    • Check the permissions on /usr/local/bin and make sure that you own that directory and have write permissions on it

      $ ls -ld /usr/local/bin

    • Once you've fixed that, run 'brew link' to fix the symlinks

      $ brew link mongodb

    0 讨论(0)
  • 2021-02-19 22:35

    Works perfectly

    1. brew update
    2. brew tap mongodb/brew
    3. brew install mongodb-community@4.2

    For latest version, check https://docs.mongodb.com/manual/release-notes/

    0 讨论(0)
  • 2021-02-19 22:35

    If you are on mongodb-community@4.0. You can try to reinstall with brew reinstall mongodb-community@4.0.

    Then I get the following hint:

    ==> Caveats
    mongodb-community@4.0 is keg-only, which means it was not symlinked into /usr/local,
    because this is an alternate version of another formula.
    
    If you need to have mongodb-community@4.0 first in your PATH run:
      echo 'export PATH="/usr/local/opt/mongodb-community@4.0/bin:$PATH"' >> ~/.bash_profile
    

    So you can just copy the echo command and restart your shell!

    0 讨论(0)
  • 2021-02-19 22:35

    It works from the directory since the sh searches the ENV path and then the cwd for a program named mongod. I have been looking around a little and it seems that the default install of MongoDB (I am not a Mac user) does not install a rc or init script for which sh to understand it's running behaviour as stated here:

    http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/#using-mongodb-from-homebrew-and-macports

    The packages installed with Homebrew and MacPorts contain no control scripts or interaction with the system’s process manager.

    If you have configured Homebrew and MacPorts correctly, including setting your PATH, the MongoDB applications and utilities will be accessible from the system shell. Start the mongod process in a terminal (for testing or development) or using a process management tool.

    So you must actually define (as you said) MongoDBs path, here is an example: https://snipt.net/sido/installing-mongodb-on-os-x/

    Edit: the example is not mine. I just stole it from it's user: https://snipt.net/sido/

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