Mac 搭建MongoDB
1.Update Homebrew’s package database.
In a system shell, issue the following command:
brew update
2.Install MongoDB.
You can install MongoDB via brew with several different options. Use one of the following operations:
Install the MongoDB Binaries
To install the MongoDB binaries, issue the following command in a system shell:
brew install mongodb
Install the Latest Development Release of MongoDB
To install the latest development release for use in testing and development, issue the following command in a system shell:
brew install mongodb --devel
3.配置MongoDB
創建數據庫文件存放地和log存放地。
mkdir -p ~/Data/MongoDB/db
mkdir -p ~/Data/MongoDB/log
cd ~/Data/MongoDB/log
vim mongo.log
接下來修改mongodb的配置文件:
vim /usr/local/etc/mongod.conf
我的是:
systemLog:
destination: file
path: ~/Data/mongoDB/log/mongo.log
logAppend: true
storage:
dbPath: ~/Data/mongoDB/db
net:
bindIp: 127.0.0.1
將上面systemLog的path改成自己的log位置,
將dbPath的位置改成自己db的位置。
4.運行
mongod --config /usr/local/etc/mongod.conf # 啓動