Today we are going to learn how to install and launch MongoDB on macOS.
We are going to start with the prerequisites, MongoDB Installation, How to launch MongoDB and the Default configuration files.
Introduction
MongoDB is a cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas.
In this tutorial, we are going to set up step by step MongoDB on macOS.
1. Prerequisites
Homebrew
Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple's macOS operating system and Linux.
First of all, you need to verify is homebrew is already installed with the command :
brew -v
// Output if itβs installed
// Homebrew 2.4.15
// Homebrew/homebrew-core (git revision 872ea; last commit 2020-08-31)
To install it, we need to use the command below :
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
It can take a while to install just be patient.
For further documentation, you can check out this link.
2. MongoDB Installation
First, we need to up brew dependencies with the command :
brew update
After we need to find the MongoDB Tap:
brew tap mongodb/brew
brew tap adds more repositories to the list of formulae that brew tracks, updates, and installs from. By default, tap assumes that the repositories come from GitHub.
We can install now MongoDB community Edition on our Computer using this command:
brew install mongodb-community
3. Launch MongoDB
To have launchd start mongod immediately and also restart at login, use:
brew services start mongodb-community
To connect to mongodb use the command :
mongo
If there is an error
if for any reason you have an error, open a new terminal window and run the command:
mongod
wait for 15 seconds and then rerun the command
mongo
in another terminal.
4. Default Configuration Files
The configuration file (/usr/local/etc/mongod.conf)
The log directory path (/usr/local/var/log/mongodb)
The data directory path (/usr/local/var/mongodb)
Congratulations.
We have successfully install and launch mongodb.
Top comments (0)