Skip to content

Instantly share code, notes, and snippets.

@nrollr
Last active August 7, 2024 02:30
Show Gist options
  • Save nrollr/9f523ae17ecdbb50311980503409aeb3 to your computer and use it in GitHub Desktop.
Save nrollr/9f523ae17ecdbb50311980503409aeb3 to your computer and use it in GitHub Desktop.
Install MongoDB on Sierra using Homebrew

Install MongoDB on macOS Sierra

This procedure explains how to install MongoDB using Homebrew on macOS Sierra 10.12.
Official MongoDB install documentation: here

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MongoDB

At this time of writing, Homebrew has MongoDB version 3.2.10 as default formulae in its main repository :

  • Enter the following command : $ brew info mongodb
  • Expected output: mongodb: stable 3.2.10 (bottled)

To install MongoDB enter : $ brew install mongodb

Additional configuration

Homebrew

To load and start the MongoDB background service, open Terminal and execute the following commands :

  • Install brew services first : $ brew tap homebrew/services

  • Load and start the MongoDB service : $ brew services start mongodb.
    Expected output : Successfully started mongodb (label: homebrew.mxcl.mongodb)

  • Check of the MongoDB service has been loaded : $ brew services list 1

  • Verify the installed MongoDB instance : $ mongod --version.
    Expected output : db version v3.2.10

Comments

1 The brew services start mongodb - instruction is equal to :

ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
@juliecious
Copy link

Thank you!

@vidukapoor
Copy link

vidukapoor commented Sep 24, 2018

thanks, thats a easy one. :)

@nadtakanfuthoem
Copy link

thank you

@dong-dev
Copy link

is there a way to specify a path to mongod.conf when running mongod using brew command?
Sth like: brew services start mongodb -f path/to/mongod.conf

Default service run by /usr/local/opt/mongodb/homebrew.mxcl.mongodb.plist
so you can see default mongo conf file at /usr/local/etc/mongod.conf, replace with your own
then run brew services start mongodb
or brew services start mongodb if mongodb service started

@wei-li-2016
Copy link

Thanks

@haochenpan
Copy link

sudo chmod 777 /data/db

Thank you!

@matthewmjm
Copy link

after about 2 hours of trying all sorts of things, I finally got it to work thanks to you. THANK YOU!!

@jetobe95
Copy link

jetobe95 commented Feb 28, 2019

Thankssss for tutoriall!!!

@stus3y
Copy link

stus3y commented Apr 2, 2019

Thanks a lot!

@Bestchoice233
Copy link

Thanks so much!!!

@ianhernandez
Copy link

✌️

@calvinbcoding
Copy link

thank you sir,
THANK YOU

@kheengz
Copy link

kheengz commented Feb 6, 2020

for MacOS Catalina

First, you install Homebrew. If you’re curious about what Homebrew is, read this article.

# Installs Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Second, find the MongoDB tap.

brew tap mongodb/brew

Third, install MongoDB.

brew install mongodb-community

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment