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