Categories: TutorialsUbuntu

How to Install MongoDB on Ubuntu 22.04

MongoDB is a real popular way to store and manage lots of unstructured or semi-structured data. It’s a type of database that focuses on documents, so you can be more flexible with the structure of your data than you could with a more traditional database.

A lot of people use MongoDB in web and mobile apps, and other places where you need to move and work with data really fast. It can handle huge amounts of data without slowing down, and it can work with different kinds of data models and languages.

Some of the reasons why people like MongoDB are that it’s good at handling really complicated data, it’s flexible when it comes to indexing, and it can handle being distributed across lots of different machines. And there are lots of tools and ways to work with data in MongoDB, which makes it a good choice for people who are building apps or studying data.

Sponsored

We’ll show you how to install MongoDB on Ubuntu 22.04, so you can get started with this powerful database tool. Our article will walk you through the entire process, including setting up and configuring MongoDB to work with your system. Whether you’re an experienced developer or new to MongoDB, keep reading to learn how to get up and running with this flexible database system on Ubuntu 22.04.

Read: How to create a user in MongoDB

Installing Mongodb on Ubuntu 22.04

To get started with Mongodb installation, open up the terminal and run the command provided below.

sudo wget -qO – https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add –

Next , execute the command:

sudo echo “deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list

To update your repositories, invoke the command :

sudo apt-get update -y

Read: How to install MongoDB on Ubuntu 20.04 or 18.04

Next, run the command :

sudo wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb

And then :

sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb

Finally, to install Mongodb, run the command :

sudo apt-get install -y mongodb-org

Install Mongodb Ubuntu

After the installation finishes, you’ll likely see a message that looks like this:

Read: How to Create and Manipulate SQL Database with Python

To check the status of the Mongodb status, execute the command:

sudo systemctl status mongod.service

Sponsored

To start the Mongodb service, run the command:

sudo systemctl start mongod

Now you can check the status again :

sudo systemctl status mongod.service

To make sure MongoDB is always available when you start your computer, you’ll need to enable the MongoDB service to run automatically at startup. This can be done by running the command:

sudo systemctl enable mongod.service

Now in order to connect to Mongodb , invoke the following command:

sudo mongosh

Read: How to install MySQL on Ubuntu 18.04

Now you should be able to start working with Mongodb.

For instance, to create a mongodb database called myDatabase , run the command :

To insert a collection of employees, execute :

MongoDB create a collection

After creating the collection, you can add new documents to it by utilizing the insertOne() or insertMany() methods. To illustrate, suppose you want to include a document with “John Doe” as the name, “Manager” as the title, and “Sales” as the department, you can enter the subsequent command:

You have the flexibility to add any number of fields to each document, and you can modify or delete documents with the help of different methods provided by MongoDB.

Read: How to install Node.js on Linux/Ubuntu

How to uninstall mongodb

In order to remove Mongodb on Ubuntu, run the command below:

sudo apt remove mongodb-org

And finally, execute:

sudo apt autoremove

Conclusion

Setting up MongoDB on Ubuntu 22.04 is an uncomplicated process that can be completed in just a few easy steps. With the help of the guidelines presented in this article, you will be able to effortlessly install and set up MongoDB on your system. Whether you are a developer who wants to integrate MongoDB into your projects or simply someone who wants to learn more about this versatile database system, we hope that this article has given you the direction and knowledge you need to begin.

 

The post How to Install MongoDB on Ubuntu 22.04 appeared first on net2.

Ubuntu Server Admin

Recent Posts

Canonical announces 12 year Kubernetes LTS

Canonical’s Kubernetes LTS (Long Term Support) will support FedRAMP compliance and receive at least 12…

23 hours ago

Ubuntu Weekly Newsletter Issue 878

Welcome to the Ubuntu Weekly Newsletter, Issue 878 for the week of February 2 –…

2 days ago

How your feedback shapes the way we support open source software

At Canonical, we firmly believe that delivering an outstanding, customer-centric support experience is impossible without…

2 days ago

How To Install osTicket v1.14 On Ubuntu 20.04

I want to share how to install osTicket v1.14 for Ubuntu 20.04 server. osTicket written…

3 days ago

How To Install WordPress On Ubuntu 20.04

Now I want to share how to install WordPress on ubuntu 20.04 server. WordPress is…

3 days ago

How To Install DNS Server (Bind9) On Ubuntu 20.04

Now I want to share the DNS server installation process on your Ubuntu 20.04 server.…

3 days ago