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
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 = 127.0.0.1
After editing:
1.ESC
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 = 0.0.0.0.
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 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
https://robomongo.org/
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!