Skip to content

Instantly share code, notes, and snippets.

@nrollr
Last active April 1, 2024 16:23
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
@nfbalbontin
Copy link

thanks!

@SatyaPraksashSolanki
Copy link

thanks.!!

@anilpai
Copy link

anilpai commented Dec 18, 2017

These instructions will fail if you don't have proper permissions to db directory.

sudo mkdir -p /data/db
sudo chmod 777 /data/db

@t1war1
Copy link

t1war1 commented Dec 28, 2017

how to install without ssl version of mongodb ?

@MatthewWyn
Copy link

Thank you for this.
Does it normally take like 10 minutes for Homebrew to download/install?
I have a good spec Mac Air and excellent internet connection.

@tjfwalker
Copy link

@MatthewWyn, no, i don't think so. I've an older MacBook Pro w/ decent internet connection and the download took less than a minute.

@DinocomM
Copy link

it works also perfectly on a mac os high sierra.

After this you can manage the mongodb with robomongo for mac, just download it from here

Thank you!!

@playground
Copy link

How to tell "brew services start mongodb" to use /data/db?

@mitridate
Copy link

dyld: Symbol not found: _syslog$DARWIN_EXTSN
Referenced from: /usr/local/bin/mongod
Expected in: /usr/lib/libSystem.B.dylib
in /usr/local/bin/mongod
Abort trap: 6

@dmp1007
Copy link

dmp1007 commented Feb 16, 2018

Thank you!

@mallowigi
Copy link

Why the fuck isn't this on the official documentation!?

@pgbezerra
Copy link

You can open a MR, @mallowigi and will be in official documentation.

@chhaymenghong
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

@hugazo
Copy link

hugazo commented May 11, 2018

life saver, thanks.

@wdlv
Copy link

wdlv commented May 21, 2018

Couldn't find the path to mongod.conf since it is not under /etc/.

@wdlv
Copy link

wdlv commented May 21, 2018

FYI: I find that mongod.conf is under /usr/local/etc/

@vixduong
Copy link

Thanks 👍

@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