简体   繁体   English

如何在Apple M1芯片上安装Mongodb

[英]How to install Mongodb on Apple M1 chip

I'm trying to install Mongodb community server on macbook air with the new M1 chip following the official mongodb tutorial .我正在尝试按照官方 mongodb 教程使用新的 M1 芯片在 macbook air 上安装 Mongodb 社区服务器。 However im running into this problem.但是我遇到了这个问题。

~ ❯❯❯ brew install mongodb-community@4.4                                
Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
  https://docs.brew.sh/Installation
You can migrate your previously installed formula list with:
  brew bundle dump

Any help with installing mongodb on m1 would be very helpful在 m1 上安装 mongodb 的任何帮助都会非常有帮助

I was getting the same problem, on the MacBook pro m1.我在 MacBook pro m1 上遇到了同样的问题。 I changed the terminal settings to Rosetta and then tried to install the brew.我将终端设置更改为 Rosetta,然后尝试安装 brew。

For this process, tap with double fingers on the terminal and click on Get Info, and in the menu, click on Open using Rosetta.在此过程中,用双指点击终端并单击获取信息,然后在菜单中单击使用 Rosetta 打开。
Now restart the terminal again and try to install the brew again with this link in the terminal.现在再次重新启动终端并尝试在终端中使用此链接再次安装 brew。

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

Now your brew is installed, use this to install MongoDB now, it will work smoothly.现在你的brew已经安装好了,现在用它来安装MongoDB,它会顺利运行的。 You can check the documentation for further process, as it won't make more issues.您可以查看文档以了解进一步的过程,因为它不会产生更多问题。
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/ https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/

This was a problem with brew and fish shell.这是 brew 和 fish shell 的问题。 It works now when installing from bash.从 bash 安装时,它现在可以工作。 Mods can remove this or whatever they like模组可以删除这个或他们喜欢的任何东西

Article on how to install mongodb on apple m1 using homebrew关于如何使用自制软件在苹果 m1 上安装 mongodb 的文章

  1. Install homebrew from https://brew.sh/https://brew.sh/安装自制软件
  2. Install xcode command line using使用安装 xcode 命令行

xcode-select --install xcode-选择--安装

  1. Now to install mongodb use现在安装 mongodb 使用

brew tap mongodb/brew酿造水龙头 mongodb/酿造

brew install mongodb-community@5.0酿造安装 mongodb-community@5.0

  1. To check if mongodb has been installed use要检查 mongodb 是否已安装,请使用

mongo --version蒙戈--版本

  1. to start mongoDB as macOS service use启动 mongoDB 作为 macOS 服务使用

brew services start mongodb-community@5.0酿造服务启动 mongodb-community@5.0

and to stop mongoDB to run as a background service use并停止 mongoDB 作为后台服务使用

brew services stop mongodb-community@5.0酿造服务停止 mongodb-community@5.0

Or, if you don't want/need a background service you can just run:或者,如果您不想要/不需要后台服务,您可以运行:

mongod --config /opt/homebrew/etc/mongod.conf mongod --config /opt/homebrew/etc/mongod.conf

  1. To run mongodb commands, open a new table and run mongo要运行 mongodb 命令,打开一个新表并运行mongo

  2. To check your databases run show dbs要检查您的数据库,请运行show dbs

  1. go to https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/ and follow all steps but go 到https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/并按照所有步骤但
  2. before brew services start mongodb-community@5.0 run softwareupdate --install-rosettabrew 服务启动之前 mongodb-community@5.0运行softwareupdate --install-rosetta
  3. now run brew services start mongodb-community@5.0现在运行brew services start mongodb-community@5.0

You need to enable Rosetta in your terminal,您需要在终端中启用 Rosetta,

  1. Duplicate your terminal,复制你的终端,
  2. After clone it called "Rosetta Terminal"克隆后称为“Rosetta Terminal”
  3. Left click to enable options and select the option Get info左键单击以启用选项和 select 选项获取信息在此处输入图像描述
  4. Enable Rosetta on your terminal by click on "Open using Rosetta"通过单击“使用 Rosetta 打开”在您的终端上启用 Rosetta 在此处输入图像描述
  5. Start Rosetta terminal启动 Rosetta 终端
  6. Install homebrew from https://brew.sh/https://brew.sh/安装自制软件
  7. Install xcode command line using xcode-select --install使用xcode-select --install安装 xcode 命令行
  8. Now to install mongodb use brew tap mongodb/brew现在安装 mongodb 使用brew tap mongodb/brew
  9. Then arch -arm64 brew install mongodb-community@5.0然后arch -arm64 brew install mongodb-community@5.0
  10. If a Warning appears you need to update Xcode tools by如果出现警告,您需要通过以下方式更新 Xcode 工具
Warning: A newer Command Line Tools release is available.
Update them from Software Update in System Preferences or run:
  softwareupdate --all --install --force

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install
  1. To check if mongodb has been installed use mongo --version要检查 mongodb 是否已安装,请使用mongo --version
  2. To start mongoDB as macOS service use brew services start mongodb-community@5.0要将 mongoDB 作为 macOS 服务启动,请使用brew services start mongodb-community@5.0
  3. To stop mongoDB to run as a background service use brew services stop mongodb-community@5.0要停止 mongoDB 作为后台服务运行,请使用brew services stop mongodb-community@5.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM