How to start using mongodb 6.0 in Ubuntu 20.04 LTS

Learn how to install & start the MongoDB 6.0 database on Ubuntu 20.04 LTS Linux Focal using the command terminal for storing your data.

MongoDB is an open-source, non-relational database solution that belongs to the NoSQL databases and can be used for big data applications. It was first introduced in 2009 and freely available database system for NoSQL databases.  Instead of storing and organizing the data into tables, MongoDB uses BSON-format documents and collections of those documents to store the data. It is characterized by its high flexibility and good scalability. MongoDB is freely available under Server Side Public License (SSPL).

In addition to the free MongoDB Community Edition, there is a commercial MongoDB Enterprise Edition and fully managed cloud-based database services under the name MongoDB Atlas. MongoDB is characterized by its high flexibility and almost unlimited horizontal

NoSQL solutions fall into one of four categories:

  • Document store: Stores a variety of information within a document. For example, a document might contain all the data of a day.
  • Key-Value Store is a very simple data structure in which each record is stored as a value with a unique key. The information can be queried specifically via this key.
  • Wide-column store stores a record in a column and not in a row as usual. They are optimized to quickly find data in large data sets.
  • Graph databases store information in so-called nodes and edges. This makes it possible, for example, to represent social networks very well, in which the persons are individual nodes and their relationship with each other is represented as an edge.

Steps to install MongoDB on Ubuntu 20.04 LTS

1. Update Ubuntu 20.04

Let’s first update our system before following this tutorial for installing the latest updates available for our system.

sudo apt update && sudo apt upgrade

2. Add MongoDB Repository on Ubuntu 20.04

As we know the MongoDB packages are not available to install directly from the base repository of  Ubuntu 20.04, therefore, we need to add the official one offered by the developers of this NoSQL database.

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

 

3. Integrate the MongoDB GPG key

To ensure the packages we will receive to install this database on our Linux are from an authentic source. Add the GPG signed key by the developers of the Database server.

curl -fsSL https://pgp.mongodb.com/server-6.0.asc | \
sudo gpg -o /etc/apt/trusted.gpg.d//mongodb-server-6.0.gpg \
--dearmor

Run system update

Once you have added the repository, one more time run the system update command to refresh the APT package index cache.

sudo apt update

4. Install MongoDB 6.0 on Ubuntu 20.04

That’s it. We have configured already what we need to install “database-tools, mongosh, extra tools, mongos; database server and shell” on our Ubuntu 20.04 Linux.

Hence, just run a simple command:

sudo apt install mongodb-org
Install MongoDB 6.0 on Ubuntu 20.04

5. Start and Enable the MongoDB service

Once the installation is completed, let’s enable and also start the service of the Database server, so that we don’t need to run it again and again with system boot.

sudo systemctl enable --now mongod

to check the status:

sudo systemctl status mongod
Start and Enable the MongoDB service

6. Check the installed version

To confirm what version is exactly installed on your system, run:

mongod --version

To get the Mongo command line simply type:

mongo

Whereas to know- how to use the database commands, see the official documentation. 

7. How to Update

If any security update will be available for MongoDB version 6.0 then to get that the user just needs to run the system update command.

sudo apt update && sudo apt upgrade

8. Uninstall or Remove

Well, those who are not interested anymore in MongoDB and don’t require it, can remove the same using the below-given command:

sudo apt autoremove --purge mongodb-org

To remove the repository & GPG key, you can use the given command:

sudo rm /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo rm /etc/apt/trusted.gpg.d/mongoserver_key.gpg

Other Articles:

Steps to Install MongoDB on Rocky Linux 8 or AlmaLinux
How to install MongoDB Server on Linux Mint 18 | 19 | 20
Install MongoDB 6.0 Server on Debian 11 Bullseye
How to install MongoDB Server on Alpine Linux

1 thought on “How to start using mongodb 6.0 in Ubuntu 20.04 LTS”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.