A tutorial on how to install MongoDB using brew under Mac _mongodb

Source: Internet
Author: User
Tags brew install mongodb install mongodb mongodb

The Software Installation tool commonly used in Mac system is homebrew

Personally, it is easier to install it through brew, as described below

Install MongoDB

wenxuezhangdemacbook-pro:~ wenxuezhang$ Brew Install MongoDB

This figure shows that the installation was successful and the directory installed was/usr/local/cellar/mongodb/3.2.9

The first time you start the service side, you need to do some work here.

The default MongoDB data file is placed under the root directory data/db folder, and if it is not, create it yourself.

Wenxuezhangdemacbook-pro:data wenxuezhang$ sudo mkdir data/db

If your current environment variable has not been added to the Mongod, add the environment variables manually.

wenxuezhangdemacbook-pro:~ wenxuezhang$ Nano ~/.bash_profile
//Add MongoDB installation directory to environment variable
export path=/usr/local/ Cellar/mongodb/3.2.9/bin:${path}}

3. Do you want the environment variable to take effect immediately? Execute the shell below

SOURCE ~/.bash_profile

4. Modify the MongoDB configuration file, the default configuration file in/usr/local/etc under the mongod.conf

# Store Data In/usr/local/var/mongodb instead of the default/data/db
dbpath =/data/db
# Append Logs To/usr/loc Al/var/log/mongodb/mongo.log
logpath =/usr/local/var/log/mongodb/mongo.log
Logappend = True
# only Accept local connections
bind_ip =

After editing:


2.shift Plus:

3.wq (Save exit)

Modify to the database file write directory address, if you are ready to connect the MongoDB database of non-local environment, BIND_IP =

So now the exciting moment is coming, hahaha, try to start the next Mongod, of course, to the directory


Of course, if it starts up, it's okay to say, but when I started here, it didn't start up, because I had to assign permissions to the/data/db file.

sudo chown ' id-u '/data/db Note: ' Id-u ' indicates the account name you are currently logged in for example: sudo chown ' admin '/data/db
Finally, after restarting the Mongod, OK.

We recommend visual MongoDB Visual Tools, download installation can be


Screenshot of visual tool:

The above is a small set to introduce the Mac under the use of Brew installation MongoDB method tutorial, I hope to help you, if you have any questions welcome to my message, small series will promptly reply to everyone, here also thank you for your support cloud Habitat community site!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.