方法一:下载源码+配置环境
方法二:brew安装
博客:
mac系统下安装并开机启动mongodb_JavaScript - UCloud云社区(安装+设置开机启动)
MongDB安装提示:No available formula with the name “mongodb”。 - 简书(报错)
官网:Install MongoDB Community Edition on macOS — MongoDB Manual
运行mongodb:
terminal1:
mongod
terminal2:
mongo
关闭:
terminal2:
# 关掉 terminal1
use admin
db.shutdownServer()
# 关掉terminal2
ctrl+c
方法2的环境配置:
open -e .bash_profile
加入:
export PATH=/usr/local/Cellar/mongodb-community@4.2/4.2.9/bin:${PATH}
export HOMEBREW_NO_AUTO_UPDATE=true
或者:
export PATH=${PATH}:/usr/local/Cellar/mongodb-community@4.2/4.2.9/bin
export HOMEBREW_NO_AUTO_UPDATE=true
source ~/.bash_profile #使环境生效
备注还要防止报错:
sudo chown -R `id -u` /data/db
sudo chmod -R go+w /data/db