mac下安裝MongoDb
阿新 • • 發佈:2018-01-17
靠譜 ima -c 安裝 image class b- sof append
Mac下安裝MongoDb
背景:看了網上N篇教程,各種不靠譜,算了 自己來踩坑
1.下載
https://www.mongodb.com/dr/fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.6.2.tgz/download
https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.6.2.tgz
2.解壓
/opt/soft/mongo/
3.添加環境變量
vi ~/.bash_profile
添加
export MONGO_PATH=/opt/soft/mongo/mongodb-osx-x86_64-3.6.2 export PATH=$PATH:$MONGO_PATH/bin
生效
source ~/.bash_profile
4.添加Mongo數據庫db
mkdir /opt/soft/mongo/mongodb-osx-x86_64-3.6.2/data/
mkdir /opt/soft/mongo/mongodb-osx-x86_64-3.6.2/data/db
chmod -R 777 /opt/soft/mongo/
5.添加Mongo配置文件
mkdir /opt/soft/mongo/mongodb-osx-x86_64-3.6.2/etc
cd etc && touch mongod.conf
#mongodb config file dbpath=/opt/soft/mongo/mongodb-osx-x86_64-3.6.2/data/db logpath=/opt/soft/mongo/mongodb-osx-x86_64-3.6.2/logs/mongodb/mongod.log logappend = true bind_ip = 127.0.0.1 journal=true port = 27017 fork = true auth = false
6.添加log文件
mkdir /opt/soft/mongo/mongodb-osx-x86_64-3.6.2/logs
mkdir /opt/soft/mongo/mongodb-osx-x86_64-3.6.2/logs/mongodb/
touch mongod.log
7.啟動
mongod --config /opt/soft/mongo/mongodb-osx-x86_64-3.6.2/etc/mongod.conf
mac下安裝MongoDb