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> 
相关推荐
2501_9151063212 小时前
App 怎么上架 iOS?从准备资料到开心上架(Appuploader)免 Mac 上传的完整实战流程指南
android·macos·ios·小程序·uni-app·iphone·webview
青木狐12 小时前
关闭 macOS 屏幕捕捉 在录制或截图时显示的「录制指示浮窗」。
macos·mac
桃子不吃李子19 小时前
一些工具的使用
javascript·mongodb·node.js
LvLuffy19 小时前
mac Android Studio配置adb环境(使用adb报错 adb: command not found)
macos·adb·android studio
库奇噜啦呼21 小时前
【iOS】UICollectionView
macos·ios·cocoa
2501_915909061 天前
iOS 发布 App 全流程指南,从签名打包到开心上架(Appuploader)跨平台免 Mac 上传实战
android·macos·ios·小程序·uni-app·cocoa·iphone
岁岁岁平安1 天前
本机 MongoDB 注册系统服务、启用security认证
数据库·python·mongodb
WangHappy2 天前
Windows搭建MongoDB(2):运行数据库
mongodb
私人珍藏库2 天前
Clip Studio Paint EX v2.0.6 For MacOS – 官方版本+逆向补丁下载,M4芯片Mac实机测试好用
macos
绝世唐门三哥2 天前
MacOS-Terminal直接command解压缩文件文件夹
macos·命令行·压缩