Advance

How to Install MongoDB on Ubuntu 22.04

How to Install MongoDB on Ubuntu 22.04

Data plays a key role in technology. Due to the increasing volume of data around the world, the use of Non-relational databases or NoSQL databases has increased. Businesses and organizations have tended to use alternative tools and systems for database management. One of these tools is MongoDB, which is a compelling database. In this article, we will teach you How to Install MongoDB on Ubuntu 22.04. You can visit the packages available on the Eldernode website if you wish to purchase an Ubuntu VPS server.

Tutorial Setup MongoDB on Ubuntu 22

Recommended Article: How To Setup A Python Virtual Environment On Windows 10

What is MongoDB?

MongoDB is an open-source, flexible and scalable database system that uses non-structured query language. It is currently one of the most powerful NoSQL databases and systems. NoSQL databases are very useful for working with large datasets and distributed data. It should note that MongoDB is a type of NoSQL database system using to store large amounts of data. MongoDB supports different types of data. The MongoDB database is a tool that can manage document-based information as well as extract and store information.

Instead of storing table data like relational or classical databases, this database actually stores data with a JSON structure without a specific schema. This database is currently using by companies such as MTV Networks, Craigslist, Foursquare, and UIDAI Aadhaar. This database is currently being developed for Windows, Macintosh, Linux and Solaris operating systems.

MongoDB Features

1. Indexing: In the MongoDB database, each field is indexed in documents with primary and secondary indexes, which makes it easier to retrieve or search for data and takes less time.

2. Schema-less Database: In the MongoDB database, a single collection can hold multiple documents with a number of different fields, sizes, and content.

3. Scalability: MongoDB can be scaled horizontally using sharding. The developer selects the segmentation key that determines how the data will distribute in a set. The data is fragmented into different intervals based on the segmentation key and distributed in different sections.

4. High Performance: MongoDB performance and data persistence are very high due to its features.

5. Document Oriented: In MongoDB, all data is stored in documents instead of tables, and each document contains its own unique object ID. In these documents, data is storing in fields instead of rows and columns, and this feature makes the data more flexible.

6. Replication: MongoDB has high access and redundancy provided by Replication, which creates multiple copies of data and sends these copies to another server to retrieve data from another server in the event of a server failure.

7. Aggregation: Operations are performed on grouped data and the computed result is obtained with the help of the aggregation. It also provides different aggregations including an aggregation pipeline, map-reduce function, and single-purpose aggregation methods.

Installing MongoDB on Ubuntu 22.04

Before doing anything, update your system packages with the help of the following command:

sudo apt update

And install the required utility packages by entering the following command:

sudo apt install wget curl gnupg2 software-properties-common apt-transport-https ca-certificates lsb-release

First, you need to include the MongoDB proprietary package repository in APT resources. To do this, enter the public key of GPG MongoDB with reference to the latest release version of its stable version running the following command:

curl -fsSL https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -

MongoDB’s APT queries in the sources.list.d directory to download and install the sources of the target packages, and now you need to configure it. Before doing so, create a file called mongodb-org-5.0.list:

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

 

Configure-MongoDB-APT-Repository-Ubuntu22.04

 

Next, you need to update your Ubuntu system again. This allows the APT package manager to know where to fetch the MongoDB package for download and installation. To do this run the following command:

sudo apt update

Now it’s time to install MongoDB on your system. You can do this by entering the following command:

sudo apt install mongodb-org -y

You can install a specific version of MongoDB using the following command:

sudo apt-get install -y mongodb-org=<version> mongodb-org-database=<version> mongodb-org-server=<version> mongodb-org-shell=<version> mongodb-org-mongos=<version> mongodb-org-tools=<version>

Once the download is complete, start the MongoDB service using the following command:

sudo systemctl start mongod

You can check MongoDB status with the following command:

sudo systemctl status mongod

 

Check-MongoDB-Ubuntu22.04

 

Now enable the MongoDB database with the following command. This will keep the MongoDB database running successfully even after the system reboots:

sudo systemctl enable mongod

You can test the connection to the MongoDB database by entering the following command:

mongo --eval 'db.runCommand({connectionStatus: 1})'

You should get the port, address, version, and activation of the database in the output of the above command:

 

Check-MongoDB-Connection-Ubuntu22.04

 

Enter the following command to access the MongoDB shell:

mongo

Then you should see the following interface:

 

Access-MongoDB-on-Ubuntu22.04

 

Finally, you can access any database-related objective:

 

Query-MongoDB-on-Ubuntu22.04

 

Recommended Article: Tutorial Install Ubuntu on Windows 10 RDP

Conclusion

MongoDB is an addition to any database project that is using in many modern applications. We first introduced MongoDB and listed its features. In this article, we added the MongoDB repository to our apt instance and taught you how to install MongoDB on Ubuntu 22.04. I hope this tutorial was useful for you.

View More Posts
Marilyn Bisson
Content Writer
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.
  • Nate Carmody
    Nate Carmody
    2 weeks ago

    You need to update this to reflect the new key system in Ubuntu that does not accept apt-key input.

    Reply
    • Marilyn Bisson
      Marilyn Bisson
      1 week ago

      The required changes have been applied.

      Reply

Leave Your Comment

Your email address will not be published.

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day