Setting Up MongoDB and MongoDB Compass for Website Development

by time news

2024-02-01 15:34:20

Problems to be solved in this article

Recently, I have to help a friend build a small website. Without back-end support, I have to do many things by myself.

Speaking of databases, this site is more familiar with Firebase, but small websites need to be installed on their own hosts and cannot be exposed to the outside world. They can only be installed on the local machine. After thinking about it, I found a database similar to Firebase. What will be helpful in the future is MongoDB.

MongoDB This part will be a series of articles, mainly looking at Net Ninjia Complete MongoDB Tutorial Notes written after the instructional video.

Because Net Ninjia uses Windows as the operating system, and August uses Mac, you still have to spend time reading files and crawling articles. For example, how to install this article on Mac was almost researched through crawling, so I thought about it. After thinking about it, I decided to publish the article.

I don’t know how far this series of articles will go. After all, there is a Chinese New Year in the middle, and I have a lot of things to do before March, so I will take a look first.

Docker install MongoDB

Official documents

The main reason for choosing Docker is that you can ignore the OS under which MongoDB is installed and avoid a lot of trouble.

This machine needs to be installed first Docker

After installation, open the terminal and enter:

docker run –name mongo -p 27017:27017 -d mongodb/mongodb-community-server:latest

After the installation is successful, you will see that the Container is created. Enter the following command to see:

docker container ls

If not specified otherwise, the default PORT is 27017.

Install MongoDB Compass

MongoDB Compass is an official GUI that allows you to directly view the status of MongoDB.

Official documents

After selecting your own OS, click the download button on the file to install it.

MongoDB Compass connects to MongoDB

Open MongoDB Compass and you will see that the URI default is:

mongodb://localhost:27017

If PORT is set separately, it must be modified.

After confirming PORT, click Connect to connect to MongoDB.

Install MongoDB Shell

Official documents

Install directly using Brew here:

brew install mongosh

After the installation is successful, enter mongosh on the terminal and you will see the DB message.

Installed MongoDB Shell successfully

#MongoDB #study #notes #Install #MongoDB #Community #Mac #Docker

You may also like

Leave a Comment