2

Install and Setup MongoDB on Windows or Mac

 1 year ago
source link: https://dzone.com/articles/mongo-db-setup-windows-or-mac
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Windows

Let's look at the steps to download and install MongoDB on Windows.

To install MongoDB in Windows 11, we will download the MongoDB Community .msi installer from the MongoDB community link.

MongoDB Community Server

Step 1: Choose the current latest version in the option and select Windows as Platform. Click on Download.

Step 2: Click the downloaded MongoDB installer. Once the MongoDB setup wizard opens, click Next.

Setup Wizard

Step 3: In the next window, choose the checkbox I accept the terms and click on Next.

Terms and Conditions

Step 4: The Complete setup type installs MongoDB tools to the default location, whereas the Custom type allows us to choose the location of the executables. You can choose either type based on your need and click on Next.

choose setup type

Step 5: Select the Install MongoD as a Service checkbox. By selecting the checkbox we can configure and start MongoDB as a Windows Service during the installation. The MongoDB service executes upon successful installation.

  • Select either Run service as Network Service User or local or domain user.
    • Network Service User is a default Windows user account
    • For the local user, mention the Account domain as period(.) and type the account name and password of the user
    • For the domain user, mention the Account domain, username and password.
  • The default service name is MongoDB. You can change the service name if you already have another service name.
  • Data Directory: db path — If the directory does not exist, it creates the directory.
  • Log Directory:  log path — If the directory does not exist, it creates the directory.

Verify whether all the fields are correct and Click on Next.

Next

To install MongoDB only and not to configure MongoDB as Windows Service, uncheck the Install MongoD as a Service and Click on Next.

Step 6: MongoDB compass is an interactive tool to visualize the database and analyze and view the data changes. To install MongoDB compass with MongoDB, select the Install MongoDB Compass checkbox and Click on Next. It is optional to install MongoDB compass.

Install MongoDB Compass

Step 7: In the next window, Click on Install.

Ready to Install
Status

Step 8: Once the MongoDB installation is complete, Click Finish to exit the wizard.

Click finish

MacOS

Prerequisites

To install MongoDB in macOS, we will use the homebrew package manager. To verify whether homebrew is available in your system, run the below command:

brew -v

If you have already installed it, you will get a version of homebrew installed. Otherwise, you can install homebrew using the below command.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Homebrew requires Xcode Command line tools for MongoDB installation.

To install Xcode Command line tools, run the below command.

xcode-select --install

Choose install in the popup and click on Agree in the agreement wizard.

16795941-screenshot-2023-03-28-at-60820-pm.png
click on Agree in the agreement wizard

Once you click Agree, the software gets installed.

Downloading Software

MongoDB Installation

Run the following command in the terminal to download the homebrew formula for MongoDB tools.

brew tap mongodb/brew

Finally, to install MongoDB run the below command in the macOS terminal.

brew install [email protected]

The latest MongoDB version supports macOS 10.14 or later.

The MongoDB installation includes the mongod server and the MongoDB shell mongosh.

Verify the installation by typing mongo --version in the new terminal.

MongoDB Compass

To install MongoDB compass, a GUI tool to visualize the database, go to the below link and download it.

If you have installed MongoDB Compass, it will look like this when you open it.

You can click on connect and start working on your queries.

You can click on connect and start working on your queries.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK