使用Homebrew安装MongoDB

Pau*_* Vu 16 macos homebrew mongodb

我是MongoDB的新手,正在尝试通过Homebrew在Mac上安装MongoDB,但出现以下错误:

Error: No available formula with the name "mongodb" 
==> Searching for a previously deleted formula (in the last 
month)...
Warning: homebrew/core is shallow clone. To get complete history 
run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
Run Code Online (Sandbox Code Playgroud)

我跑 brew update 那么 brew install mongodb

Sim*_*mba 68

配方mongodb已从自制软件核心中删除。从Homebrew -Core 检查PR-43770

给我们的用户:如果您由于mongodb停止为您工作而来到这里,则由于它已迁移到非开源许可证,因此已将其从Homebrew核心公式中删除。

幸运的是,mongodb团队正在维护自定义的Homebrew水龙头。您可以卸载旧的mongodb,然后从新的水龙头重新安装新的mongodb。

brew services stop mongodb
brew uninstall mongodb

brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-community
Run Code Online (Sandbox Code Playgroud)

检查mongodb / homebrew-brew以获取更多信息。

  • 刚刚将 macOS 升级到 14.2 (23C64)。使用“/mongodb-community/7.0.2/bin”重新启动“brew services start mongodb-community”。现在出现错误:#<Formula mongodb-community (stable) /usr/local/Homebrew/Library/Taps/mongodb/homebrew-brew/Formula/mongodb-community.rb> 的未定义方法`plist_startup' (3认同)
  • 2019年9月12日上班。 (2认同)
  • @MattHagemann你可能把事情搞砸了。默认数据库位置是“/usr/lobal/var/mongodb”,可以通过“brew cat mongodb-comunnity”确认。并且不要将brew与sudo一起使用,这会更改包文件的所有者并给您带来更多麻烦。我已经在[此处](/sf/answers/4094127411/)解释过“sudobrew”的缺点。 (2认同)
  • 我遇到了同样的错误。“ #<Formula mongodb-community (stable) /opt/homebrew/Library/Taps/mongodb/homebrew-brew/Formula/mongodb-community.rb> 的未定义方法`plist_startup'” (2认同)

Saj*_*oth 12

首先安装mongodb

brew tap mongodb/brew
Run Code Online (Sandbox Code Playgroud)

其次使用此命令安装。mangodb 安装成功

brew install mongodb-community@4.0 
Run Code Online (Sandbox Code Playgroud)

你会得到输出

==> CaveatsTo 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.2.2: 21 files, 274.5MB, built in 2 minutes 46 seconds
brew services start mongodb/brew/mongodb-community
==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-commu
Run Code Online (Sandbox Code Playgroud)


A S*_*zee 11

关于macOS Big SurHomebrewmongodb 文档说明:https : //docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/

您应该安装支持 macOS 10.13 或更高版本的 MongoDB 4.4 社区版,因此这些步骤会有所帮助。

解决方案 1:如果您之前安装了旧版本的公式,您可能会遇到ChecksumMismatchError解决该问题的方法:

删除下载的 .tgz 存档。

brew untap mongodb/brew && brew tap mongodb/brew
Run Code Online (Sandbox Code Playgroud)

重新计算公式。

  brew install mongodb-community@4.4 
Run Code Online (Sandbox Code Playgroud)

解决方案 2:如果您尚未安装任何版本的公式。

1、从https://brew.sh/#install安装Xcode命令行工具和Homebrew

xcode-select --install
Run Code Online (Sandbox Code Playgroud)

2、点击MongoDB Homebrew Tap:

brew tap mongodb/brew
Run Code Online (Sandbox Code Playgroud)

3、在macOS终端中验证安装先决条件:

brew tap | grep mongodb
Run Code Online (Sandbox Code Playgroud)

4、安装MongoDB

brew install mongodb-community@4.4
Run Code Online (Sandbox Code Playgroud)

注意:安装包括:

• mongod 服务器,

• mongos 分片集群查询路由器,

• mongo 外壳

请参阅此屏幕截图:

在此处输入图片说明

最后将 MongoDB(即 mongod 进程)作为 macOS 服务运行,发出以下命令:

brew services start mongodb-community@4.4
Run Code Online (Sandbox Code Playgroud)

截屏:

在此处输入图片说明


rez*_*afi 8

在您的终端中尝试此代码:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 
Run Code Online (Sandbox Code Playgroud)

进而:

brew tap mongodb/brew  
Run Code Online (Sandbox Code Playgroud)

最后:

brew install mongodb-community@4.0
Run Code Online (Sandbox Code Playgroud)

  • 您可能还需要将“mongo”可执行文件添加到您的路径或将其添加为别名,例如“export PATH=$PATH:/usr/local/Cellar/mongodb-community@4.0/4.0.13/bin/”或`别名 mongo=/usr/local/Cellar/mongodb-community@4.0/4.0.13/bin/mongo` (2认同)