mac安装mongoDB的正确姿势

bash 复制代码
testmanzhang@TestMandeMBP corpora % brew tap mongodb/brew
bash 复制代码
testmanzhang@TestMandeMBP corpora % brew search mongodb
bash 复制代码
testmanzhang@TestMandeMBP corpora % brew install mongodb-community@7.0

依次执行上面的命令后开始安装mongoDB,但是安装过程中有很多报错,例如:

bash 复制代码
Error: openjdk: Failed to download resource "openjdk"
...
Error: pango: Failed to download resource "pango"
...
Error: ffmpeg@6: Failed to download resource "aom"
...
Error: ffmpeg: Failed to download resource "x265"
...
Error: gtk4: Failed to download resource "gtk4"
...
Error: libsoup: Failed to download resource "sqlite"
...
Error: python@3.13: Failed to download resource "python@3.13"
...
Error: gstreamer: Failed to download resource "ffmpeg"
...
Error: allure: Failed to download resource "openjdk"
...
Error: qt: Failed to download resource "qt"
...
Error: pyqt: Failed to download resource "qt"
...
Error: vtk: Failed to download resource "python@3.13"
...
Error: opencv: Failed to download resource "openvino"
...

报错有点多,可能是姿势不对,一个一个解决有点麻烦,可能有的跟mongoDB也没有关系,但是强迫症,看着不舒服,重装!

先卸载mongoDB:

bash 复制代码
testmanzhang@TestMandeMBP corpora % brew uninstall mongodb-community@7.0
bash 复制代码
testmanzhang@TestMandeMBP corpora % brew uninstall mongodb-database-tools

清除homebrew缓存:

bash 复制代码
testmanzhang@TestMandeMBP corpora % brew cleanup

删除mongoDB的残存文件:

bash 复制代码
testmanzhang@TestMandeMBP corpora % rm -rf /usr/local/var/mongodb
testmanzhang@TestMandeMBP corpora % rm -rf /opt/homebrew/var/mongodb

先更新一下homebrew:

bash 复制代码
testmanzhang@TestMandeMBP corpora % brew update

重新安装mongoDB:

bash 复制代码
testmanzhang@TestMandeMBP corpora % brew tap mongodb/brew
bash 复制代码
testmanzhang@TestMandeMBP corpora % brew install mongodb-community@7.0

这回安装比较顺利,没有报错!!!

启动mongoDB:

bash 复制代码
testmanzhang@TestMandeMBP corpora % brew services start mongodb/brew/mongodb-community@7.0
==> Successfully started `mongodb-community@7.0` (label: homebrew.mxcl.mongodb-community@7.0)

关闭mongoDB:

bash 复制代码
testmanzhang@TestMandeMBP corpora % brew services stop mongodb/brew/mongodb-community@7.0
Stopping `mongodb-community@7.0`... (might take a while)
==> Successfully stopped `mongodb-community@7.0` (label: homebrew.mxcl.mongodb-community@7.0)

连接mongoDB:

bash 复制代码
mongosh
bash 复制代码
testmanzhang@TestMandeMBP ~ % mongosh   
Current Mongosh Log ID:	67e2a00939223a773679ef31
Connecting to:		mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.4.2
Using MongoDB:		7.0.17
Using Mongosh:		2.4.2

For mongosh info see: https://www.mongodb.com/docs/mongodb-shell/

------
   The server generated these startup warnings when booting
   2025-03-25T20:22:23.392+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
------

test> 
相关推荐
喪彪9 小时前
Ubuntu操作系统下使用mysql、mongodb、redis
redis·mysql·mongodb
Digitally9 小时前
如何将视频从安卓设备传输到Mac?
android·macos
心灵宝贝11 小时前
Mac用户安装JDK 22完整流程(Intel版dmg文件安装指南附安装包下载)
java·开发语言·macos
猫猫的小茶馆15 小时前
【STM32】CubeMX(十三):RT-THREAD
stm32·单片机·嵌入式硬件·mcu·mongodb·51单片机·智能硬件
小李飞刀李寻欢17 小时前
MongoDB /redis/mysql 界面化的数据查看页面App
redis·mysql·mongodb
Magnetic_h20 小时前
【iOS】内存管理及部分Runtime复习
笔记·学习·macos·ios·objective-c·cocoa·xcode
满目82820 小时前
【Ubuntu系统实战】一站式部署与管理MySQL、MongoDB、Redis三大数据库
数据库·redis·mysql·mongodb·ubuntu·数据库布置
大新屋1 天前
MongoDB 分片集群把非分片集合转成分片集合
数据库·mongodb
2501_927539302 天前
EndNote 2025 Mac 文献管理工具
macos·mac·文献管理
coderklaus3 天前
Shell 基础知识
linux·macos·shell