Install mongodb on MacOS by steps

link   link2

For example install MondoDB 2.6.12 on macOS Catalina

  1. Download, extract and move:

    wget http://downloads.mongodb.org/osx/mongodb-osx-x86_64-2.6.12.tgz

    tar xzf mongodb-osx-x86_64-2.6.12.tgz

    mv mongodb-osx-x86_64-2.6.12/ /usr/local/mongodb/

  2. Add to file ~/.zshrc this:

    export PATH="$PATH:/usr/local/mongodb/bin"

    PS: .bash_profile or .profile not worked in my case

  3. Mkdir directory for data and set rights:

    mkdir -p ~/data/db

    chown -R mongodb.mongodb ~/data/db

  4. Run MongoDB:

    mongodb --dbpath ~/data/db