Install MongoDB on MacOS with Homebrew

- Andrés Cruz

En español
Install MongoDB on MacOS with Homebrew

Let's learn how we can install MongoDB if we are on MacOS; For this we will assume that you have Homebrew installed, which is simply a package manager for MacOS and Linux.

With our package manager, nothing could be easier, the first thing we have to do is add the MongoDB repository to our package manager.

Software required to install install MongoDB

Install Command line tools for xcode
Surely when you go to execute the Brew command to install the package, it will ask you to install the command line tools for xcode, accept and download and install these tools.

Install Homebrew

Now yes, we are going to install Homebrew, MacOS does not include the Homebrew preparation package by default; Therefore, you have to install it as indicated on the official website. https://brew.sh/#install

Homebrew installs the things you need for your MacOS from a terminal easily.

Install MongoDB Homebrew Tap

Issue the following from the terminal to tap the official MongoDB Homebrew tap: https://github.com/mongodb/homebrew-brew

This is a custom Homebrew Tap (package) for the official MongoDB software.

brew tap mongodb/brew
brew install mongodb-community@5.0

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

Start the MongoDB process

With this we now have MongoDB on our team; the next thing we are going to do is start the process, since if we execute in our terminal:

brew services start mongodb-community

Because if you don't start it and type mongo in the terminal, you will see an error like the following

It is true that an error like the following occurs:

MongoDB shell version v5.0.2
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:372:17
Andrés Cruz

Desarrollo con Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz en Udemy

Acepto recibir anuncios de interes sobre este Blog.