【MongoDB】MacOS安装MongoDB完整收录

系统版本

在这里插入图片描述

最低版本要求

10.13

MongoDB版本

MongoDB Community Edition 
4.4

安装

安装Xcode命令行

xcode-select --install

安装Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

安装MongoDB

brew tap mongodb/brew

Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (elastic/tap and homebrew/services).
==> Updated Formulae
Updated 17 formulae.
==> Deleted Formulae
elastic/tap/elasticsearch-oss            elastic/tap/kibana-oss

==> Tapping mongodb/brew
Cloning into '/usr/local/Homebrew/Library/Taps/mongodb/homebrew-brew'...
remote: Enumerating objects: 619, done.
remote: Counting objects: 100% (116/116), done.
remote: Compressing objects: 100% (112/112), done.
remote: Total 619 (delta 45), reused 13 (delta 4), pack-reused 503
Receiving objects: 100% (619/619), 133.57 KiB | 124.00 KiB/s, done.
Resolving deltas: 100% (283/283), done.
Tapped 11 formulae (39 files, 208.7KB).
brew install mongodb-community@4.4

Updating Homebrew...
==> Installing mongodb-community from mongodb/brew
==> Downloading https://fastdl.mongodb.org/tools/db/mongodb-database-tools-macos
######################################################################## 100.0%
==> Downloading https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.4.4.tgz
######################################################################## 100.0%
==> Installing dependencies for mongodb/brew/mongodb-community: mongodb-database-tools
==> Installing mongodb/brew/mongodb-community dependency: mongodb-database-
🍺  /usr/local/Cellar/mongodb-database-tools/100.3.1: 13 files, 150.9MB, built in 6 seconds
==> Installing mongodb/brew/mongodb-community
==> Caveats
To have launchd start mongodb/brew/mongodb-community now and restart at login:
  brew services start mongodb/brew/mongodb-community
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.4.4: 11 files, 156.9MB, built in 4 seconds
==> `brew cleanup` has not been run in 30 days, running now...
Removing: /Users/lixiaoyu/Library/Caches/Homebrew/gdbm--1.18.1_1.big_sur.bottle.tar.gz... (207.3KB)
Removing: /Users/lixiaoyu/Library/Caches/Homebrew/mycli--1.22.2_1.big_sur.bottle.tar.gz... (4.0MB)
Removing: /Users/lixiaoyu/Library/Caches/Homebrew/mysql-client--8.0.22.big_sur.bottle.tar.gz... (42.3MB)
Removing: /Users/lixiaoyu/Library/Caches/Homebrew/nginx--1.19.5.big_sur.bottle.tar.gz... (1.2MB)
Removing: /Users/lixiaoyu/Library/Caches/Homebrew/openssl@1.1--1.1.1i.big_sur.bottle.tar.gz... (5.4MB)
Removing: /Users/lixiaoyu/Library/Caches/Homebrew/python@3.8--pip--20.2.4.tar.gz... (1.4MB)
Removing: /Users/lixiaoyu/Library/Caches/Homebrew/python@3.8--wheel--0.35.1.tar.gz... (58.3KB)
Removing: /Users/lixiaoyu/Library/Caches/Homebrew/python@3.8--setuptools--50.3.2.zip... (2.0MB)
Removing: /Users/lixiaoyu/Library/Caches/Homebrew/python@3.8--3.8.6.tar.xz... (17.4MB)
Removing: /Users/lixiaoyu/Library/Caches/Homebrew/python@3.9--setuptools--51.0.0.zip... (2.0MB)
Removing: /Users/lixiaoyu/Library/Caches/Homebrew/python@3.9--pip--20.3.1.tar.gz... (1.5MB)
Removing: /Users/lixiaoyu/Library/Caches/Homebrew/python@3.9--wheel--0.36.1.tar.gz... (62.7KB)
Removing: /Users/lixiaoyu/Library/Caches/Homebrew/python@3.9--3.9.1.tar.xz... (18MB)
Removing: /Users/lixiaoyu/Library/Caches/Homebrew/readline--8.1.big_sur.bottle.tar.gz... (536KB)
Removing: /Users/lixiaoyu/Library/Caches/Homebrew/sqlite--3.34.0.big_sur.bottle.tar.gz... (2.0MB)
Removing: /Users/lixiaoyu/Library/Logs/Homebrew/mkcert... (64B)
Removing: /Users/lixiaoyu/Library/Logs/Homebrew/nss... (64B)
Removing: /Users/lixiaoyu/Library/Logs/Homebrew/nspr... (64B)
==> Caveats
==> mongodb-community
To have launchd start mongodb/brew/mongodb-community now and restart at login:
  brew services start mongodb/brew/mongodb-community
Or, if you don't want/need a background service you can just run:
  mongod --config /usr/local/etc/mongod.conf

我好久没更新了,所以上面有一段自动更新。

运行

作为服务运行(推荐)

开启服务

brew services start mongodb-community@4.4

==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-community)

验证运行

brew services list | grep mongodb

mongodb-community  started lixiaoyu /Users/coderfix.blog.csdn.net/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist

结束服务

brew services stop mongodb-community@4.4

Stopping `mongodb-community`... (might take a while)
==> Successfully stopped `mongodb-community` (label: homebrew.mxcl.mongodb-community)

作为后台进程

开启进程

mongod --config /usr/local/etc/mongod.conf --fork

about to fork child process, waiting until server is ready for connections.
forked process: 39626
child process started successfully, parent exiting

验证运行

ps aux | grep -v grep | grep mongod

coderfix.blog.csdn.net         39626   0.2  0.2  5529296  20416   ??  S     3:50下午   0:01.04 mongod --config /usr/local/etc/mongod.conf --fork

结束进程

kill 39626

39626是上面的进程号

命令行进入mongo

mongo

connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("657fd4ef-6986-4b55-b694-625710e2cbe9") }
MongoDB server version: 4.4.4
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
	https://docs.mongodb.com/
Questions? Try the MongoDB Developer Community Forums
	https://community.mongodb.com
---
The server generated these startup warnings when booting: 
        2021-04-23T15:59:42.655+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
---
---
        Enable MongoDB's free cloud-based monitoring service, which will then receive and display
        metrics about your deployment (disk utilization, CPU, operation statistics, etc).

        The monitoring data will be available on a MongoDB website with a unique URL accessible to you
        and anyone you share the URL with. MongoDB may use this information to make product
        improvements and to suggest MongoDB products and deployment options to you.

        To enable free monitoring, run the following command: db.enableFreeMonitoring()
        To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---

总结

  • 推荐服务形式运行

后续我会继续更新相关学习笔记,敬请期待!!!

参考资料

  • https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
  • https://brew.sh/#install
  • https://docs.mongodb.com/manual/reference/program/mongod/#mongodb-binary-bin.mongod
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小雨青年

程序员可以把咖啡转化成代码~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值