Mac下mongo的安装和配置

Mac下mongo的安装和配置

1. 前提

brew tap mongodb/brew # brew tap 三方源
brew search mongo # 确认是否已安装, 查找mongo合适的版本

2. 安装并配置

2.1. 安装

liuxianqiang-mac:/ liuxianqiang$ brew install mongodb-community@4.2
==> Installing mongodb-community@4.2 from mongodb/brew
==> Downloading https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.2.9.tgz
######################################################################## 100.0%
==> Caveats
mongodb-community@4.2 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have mongodb-community@4.2 first in your PATH run:
  echo 'export PATH="/usr/local/opt/mongodb-community@4.2/bin:$PATH"' >> /Users/liuxianqiang/.bash_profile


To have launchd start mongodb/brew/mongodb-community@4.2 now and restart at login:
  brew services start mongodb/brew/mongodb-community@4.2
Or, if you don't want/need a background service you can just run:
  mongod --config /usr/local/etc/mongod.conf
==> Summary
🍺  /usr/local/Cellar/mongodb-community@4.2/4.2.9: 21 files, 306.4MB, built in 6 seconds

2.2. 配置环境变量 (~/.bash_profile)

# Mongo
PATH=$PATH:/usr/local/opt/mongodb-community@4.2/bin

3. 运行

brew services start mongodb/brew/mongodb-community@4.2 # 启动
brew services stop mongodb/brew/mongodb-community@4.2 # 停止
brew services restart mongodb/brew/mongodb-community@4.2 # 重启

4.验证

mongo --version
mongo --help
mongo # 注意, mongo初始安装, 默认没有用户名和密码

5. 参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值