Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. However im running into this problem.

~ ❯❯❯ brew install [email protected]                                
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

like image 866
Glutch Avatar asked Dec 18 '20 13:12

Glutch


People also ask

Is MongoDB available for Mac M1?

MongoDB works as a distributed database and makes data access easy. There are two methods to install MongoDB on mac: Installing MongoDB using brew (recommended) Installing MongoDB by downloading from official website.

How do I install MongoDB on my Macbook Pro?

Go to the MongoDB website's download section and download the correct version of MongoDB. Run the Mongo daemon, in one terminal window run ~/mongodb/bin/mongod . This will start the Mongo server. Run the Mongo shell, with the Mongo daemon running in one terminal, type ~/mongodb/bin/mongo in another terminal window.

Does MongoDB support Apple silicon?

⚠️ Yes, Rosetta 2 only.


2 Answers

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 [email protected]

  4. To check if mongodb has been installed use

    mongo --version

  5. to start mongoDB as macOS service use

    brew services start [email protected]

    and to stop mongoDB to run as a background service use

    brew services stop [email protected]

    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/

like image 87
Hitesh Meta Avatar answered Nov 15 '22 07:11

Hitesh Meta


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/

like image 36
Saurabh Avatar answered Nov 15 '22 07:11

Saurabh