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 = 127.0.0.1
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 = 0.0.0.0 is available.
So now the exciting moment is coming, hahaha, try to start the next Mongod, of course to the directory
/usr/local/cellar/mongodb
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.
https://robomongo.org/
Visualization tools:
Mac under Brew install MongoDB