Installing MongoDB - Mac OS X
Among different ways of installing MongoDB on Mac OS X, I recommend the simplest way of installing and configuring by using Homebrew with
CURL command from MongoDB binaries. If Homebrew has not already installed on your machine, following the steps in Installing Homebrew section below in this post.
1. First, Type
brew update to update Homebrew to latest version.
2. There are several different options in installing MongoDB. If you want to install only MongoDB Binaries, type
brew install mongodb. If you want MongoDB built from Source with TLS/SSL Support, type
brew install mongodb --with-openssl. If you prefer the latest development release, type
brew install mongodb --devel.
3. In this post, I will go with ordinary MongoDB binaries. It will take a few seconds for downloading and compiling MongoDB components in your system files.
- Before you can start MongoDB for the first time, you need to define the default directory where all the data being saved that
sudo mkdir -p /data/dbin Terminal to create default /data/db folder in your disk root directory.
- Type your admin-level password when prompt.
- Before running
mongodprocess for the first time, make sure that you have both read and write permissions for the
/data/dbdirectory. The permission has been already set normally. If not, type 'sudo chmod 777 /data/db' to change permissions security settings for
- Then, you can type
mongodin Terminal to start Mongod process which is a background service instance for MongoDB. You will see multiple lines in Terminal window like the following ss.
- To stop
Ctrl + cin the Terminal window where the mongod instance is running.
- Visit http://brew.sh/, the official page of Homebrew.
- You can directly paste this command in Terminal or copy from its page.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- You will see a dialog box to install Xcode or Command line developer tools from the App Store after entering above
xcruncommand. You can simply press
Installin that dialog box or
Get Xcodefrom App Store.
- After installing Command line developer tools, press
Returnto continue installing Homebrew.
- Type your admin-level password if prompt.
- You will see Installation successful! after a moment. Then, Homebrew is successfully installed on your machine.