Mac under Brew install MongoDB

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

A common software Installation tool for Mac systems is homebrew

Personally, it is easy to install through brew, and the following describes how to install

Installing MongoDB

wenxuezhangdemacbook-pro:~ wenxuezhang$ Brew Install MongoDB

This figure illustrates that the installation is successful and the directory that is installed is/usr/local/cellar/mongodb/3.2.9

The first time you start the server, you need to do some preparatory work here.

The default MongoDB data file is placed in the root directory data/db folder, if you do not have this file, please create it yourself.

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

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

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

3. If the environment variable takes effect immediately? Execute the following shell

SOURCE ~/.bash_profile

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

# Store Data In/usr/local/var/mongodb instead of the Default/data/dbdbpath =/data/db# Append logs To/usr/local/var/log /mongodb/mongo.loglogpath =/usr/local/var/log/mongodb/mongo.loglogappend = true# only accept local connectionsbind_ip =
After editing:

3.wq (Save exit)

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

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


Of course, if it started up fortunately, but when I started here, it was not started, the reason is 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 into such as: sudo chown ' admin '/data/db

Finally, restart the mongod on the OK.

We recommend that you visualize MongoDB visualization tools, download and install it.

Visualization tools:

Mac under Brew install MongoDB

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: 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.