How to Install MongoDB on macOS
Jack Wallen will guide you through simple steps to install NoSQL database, MongoDB, on macOS.
For those who have tried, installing MongoDB on the latest Ubuntu 22.04 released is no headache. The reason for this is that Ubuntu no longer supports libssl1.1, which is still a requirement for MongoDB. I have been trying to install and run this powerful NoSQL database on Jammy Jellyfish but no luck. I can install it, but it always fails at start.
I also found it problematic to install MongoDB on AlmaLinux. So I switched to another operating system for my MongoDB needs: macOS. With macOS, getting MongoDB up and running is pretty straightforward, as long as you know how to use Homebrew.
Let me show you how.
UNDERSTAND: Recruitment Toolkit: Database Engineer (TechRepublic Premium)
What you need
The only thing you need to make this work is a macOS device. I’ll be demonstrating on a MacBook Pro. Be busy.
How to install Homebrew
The first thing you need to do is install Homebrew, which is a command-line package manager for macOS and a must-have for power users. To install Homebrew, log into your macOS device and open the terminal from Launchpad. With the terminal open, execute the following command:
/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”
That installation will take some time to complete successfully.
How to install MongoDB
With Homebrew installed, we can now install MongoDB. We will be installing the latest version of the database server (v6). Before running the install command, we must first touch MongoDB with Homebrew, using the command:
brew tap mongodb / brew
Once the process is complete, we can install MongoDB with the command:
brew install [email protected]
Again, this command will take some time to complete. Once done, MongoDB is installed and ready to start.
How to start MongoDB
To start and enable the MongoDB server, issue the command:
brew service starts mongodb/brew/mongodb-community
To make sure the service is running, issue the command:
list of brewing services
You should see that the service has started successfully (Picture A).
Picture A
How to connect to MongoDB shell
To access the MongoDB shell, issue the command:
mongosh
Congratulations, you now have MongoDB 6.0 Community Edition running on macOS. Now you can start building your database for any project you have in mind.
Subscribe to TechRepublic’s How to make technology work on YouTube for all the latest tech advice for business professionals from Jack Wallen.