20

I'm trying to install Mongodb community server on macbook air with the new M1 chip following the official mongodb tutorial. 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

Glutch
  • 662
  • 1
  • 6
  • 19

5 Answers5

38

Article on how to install mongodb on apple m1 using homebrew

  1. Install homebrew from https://brew.sh/

  2. Install xcode command line using

    xcode-select --install

  3. Now to install mongodb use

    brew tap mongodb/brew

    brew install mongodb-community@6.0

  4. To check if mongodb has been installed use

    mongo --version

  5. to start mongoDB as macOS service use

    brew services start mongodb-community@6.0

    and to stop mongoDB to run as a background service use

    brew services stop mongodb-community@6.0

    Or, if you don't want/need a background service you can just run:

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

  6. To run mongodb commands, open a new table and run mongo

  7. To check your databases run show dbs

Full documentation here: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/

Hitesh Meta
  • 413
  • 5
  • 9
  • Make the terminal settings to use Rosetta. Select the app(Terminal) in the Finder. Note that the "Terminal app" could be at "Applications/Utilities". Right click on the app(Terminal) and select Get Info. In General, check the Open using Rosetta check-box. – Sudip Ghosh Feb 26 '23 at 15:50
  • `mongo --version` seems not working. instead `mongod --version` worked for me. – ATUL DIVEDI Jun 10 '23 at 19:08
7

I was getting the same problem, on the M1 MacBook Pro. I changed the terminal settings to Rosetta and then tried to install the 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.

Now restart the terminal again and try to install the brew again with this link in the terminal.

/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. 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/

TylerH
  • 20,799
  • 66
  • 75
  • 101
Saurabh
  • 71
  • 4
4

You need to enable Rosetta in your terminal,

  1. Duplicate your terminal,
  2. After clone it called "Rosetta Terminal"
  3. Left click to enable options and select the option Get info enter image description here
  4. Enable Rosetta on your terminal by click on "Open using Rosetta"enter image description here
  5. Start Rosetta terminal
  6. Install homebrew from https://brew.sh/
  7. Install xcode command line using xcode-select --install
  8. Now to install mongodb use brew tap mongodb/brew
  9. Then arch -arm64 brew install mongodb-community@5.0
  10. If a Warning appears you need to update Xcode tools by
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
  2. To start mongoDB as macOS service use 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
3
  1. go to https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/ and follow all steps but
  2. before brew services start mongodb-community@5.0 run softwareupdate --install-rosetta
  3. now run brew services start mongodb-community@5.0
Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50
1nstinct
  • 1,745
  • 1
  • 26
  • 30
1

This was a problem with brew and fish shell. It works now when installing from bash. Mods can remove this or whatever they like

Glutch
  • 662
  • 1
  • 6
  • 19
  • Yes, because thats the purpose of Stackoverflow. Delete the question, whenever you get an answer :-D – FooBar Mar 29 '22 at 20:33