How To Install and Configure MongoDB in macOS Using Homebrew

How To Install and Configure MongoDB in macOS Using Homebrew

Hi guys welcome back to Ask MHS and it's time to learn about How To Install asnd Configure MongoDB in macOS Sierra Using Homebrew in macOS. So this is the easy way to install and and configure MongoDB in macOS and obviously we need tool named "Homebrew" to install MongoDB. If you have not installed Homebrew, you have to install Homebrew first by following this tutorial but if you have you can skip this step.

Installation :
1. Open your Terminal
2. Update Homebrew’s package database using the following command:
brew update
3. Install the MongoDB Binaries, there are 3 options and you can choose which one you need:

  • To Install MongoDB in default option
brew install mongodb

  • To install the MongoDB binaries that have TLS/SSL support
brew install mongodb --with-openssl

  • To install the latest development release for use in testing and development
brew install mongodb --devel
How To Install and Configure MongoDB in macOS Using Homebrew
Alright, we've installed MongoDB in our macOS. The next step is configure the MongoDB so we can run MongoDB easily. Here are the steps:

1. Creating the data directory
This is the important thing we need to do before we can run MongoDB in our Mac. So we will create folder /data/db because by default mongodb process will uses this directory. Obviously you can specify in which directory you wanna use to process the mongodb but in this tutorial just create /data/db directory:
sudo mkdir -p /data/db
2. Set permissions for the data directory
sudo chmod 777 /data/db
How To Install and Configure MongoDB in macOS Using Homebrew
3. Run MongoDB

mongod
How To Install and Configure MongoDB in macOS Using Homebrew
Alright we have successfully running MongoDB in our macOS.
Note : If you do not use the default data directory (i.e., /data/db), specify the path to the data directory using the --dbpath option:
mongod --dbpath <path to data directory>

So now we just wanna check to ensure that mongodb has successfully started using MongoDB client app like Robomongo, MongoHub, etc., but in this case we will use Robomongo that can be downloaded here. After it's downloaded just copy it into Applications directory and run it.

You'll be provided a window and just create new connection by clicking "create" and configure like the following picture.
How To Install and Configure MongoDB in macOS Using Homebrew
Then just save it and click Connect button. If mongodb has successfully started you will see this window:
How To Install and Configure MongoDB in macOS Using Homebrew
Alright guys that's all about How To Install and Configure MongoDB in macOS Using Homebrew. Just leave some comment if you found any mistake or have any questions. Thank you very much for visit my blog and see you next time in the next tutorial.
How To Install and Configure MongoDB in macOS Using Homebrew How To Install and Configure MongoDB in macOS Using Homebrew Reviewed by Ask MHS on November 23, 2016 Rating: 5

No comments:

Powered by Blogger.