How to install Mongodb Server on Linux mint 18 | 19 | 20

Steps and commands to install the latest version of MongoDB server and client on Linux Mint 18, 19, and 20 using the command terminal.

What is MongoDB? MongoDB is an open-source database that is different from Oracle MySQL, Microsoft SQL, and other popular SQL database servers. Because this one is based on a non-relational document model. That’s why we called NoSQL database (NoSQL = Not-only-SQL) and makes it differs fundamentally from conventional relational databases. The meaning of its name is “humongous” founded by developer Eliot Horowitz in 2009.

MongoDB is available in both community and Enterprise editions. The community version is good for SMBs, developers, individuals for testing and learning; whereas the enterprises with a heavy workload and require large-scale implementation should go for the Enterprise version. In the enterprise version, the user will get Technical support, Kubernetes Integration, advanced access control, and data security, LDAP Proxy Authentication, Encryption at Rest, Auditing, Kerberos Authentication, and other features…

Steps for MongoDB installation on Linux Mint

————————–For most stable version via ubuntu repo but old——————————–

1. Install MongoDB using Linux Mint repo

Well, the packages to install MongoDB are already available in the official Ubuntu repository of Linux Mint, hence we don’t need anything else. However, the version of the database server will not be the latest one, instead of the old but stable. Nevertheless, if you are looking for the latest version then add the MongoDB repo manually, steps are given further in this article.

APT repository Update

Refresh the system repository cache by running the update command before going further. This will install the latest updates and rebuild the repo cache.

sudo apt update

 

MongoDB installation using Ubuntu repo

Now, you can install MongoDB on your Linux Mint using the given command, however, this will fetch the packages from the official Ubuntu repository. Hence, the packages will not be the latest ones.

sudo apt install mongodb-server mongodb

MongoDB installation command

Check version

Once the installation is completed, check the installed database version.

mongo --version

Check MongoDB version

 

Uninstall or Remove

For removing your installed MongoDB server and client, simply use the APT remove command, in the following way:

sudo apt remove mongodb*
sudo apt purge mongodb
sudo apt autoremove
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb

 

———————-For latest version via MongoDB official repo——————————

2. MongoDB setup using the official repository

Well, those who want to get MongoDB’s latest version, need to add its official repository manually. Note: If you are following this tutorial then you must uninstall the MongoDB you have installed using the Ubuntu repo or the steps given above. Otherwise, you will get an error: overwrite ‘/usr/bin/bsondump‘, which is also in package mongo-tools 3 .6.3-0ubuntu1

Add GPG key

sudo apt-get install gnupg
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -

Note: When you are following this tutorial, at that time, if the version of Mongo is above 5.0 then replace it in the above command. For example- for 5.1, change the version from number 5.0 to 5.1 in the above command.

Add MongoDB repo on Linux Mint 18 | 19 | 20

As per your Mint version add the repository

For Linux Mint 18. x

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

For Linux Mint 19. x

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

For Linux Mint 20. x

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

 

Perform system update

To properly add the repository into the system, run the system update command. This will also rebuild the system repository cache.

sudo apt update

 

Install MongoDB latest version for Linux Mint

Finally, we have the repo. Now, just run the given APT package manager command to install the Database server and client on this Ubuntu-based system.

sudo apt clean
sudo apt-get install mongodb-org

 

Start and enable Database service

Although the database services will start automatically, however, to ensure run the given commands and check the status:

sudo systemctl daemon-reload
sudo systemctl start mongod
sudo systemctl enable mongod
sudo systemctl status mongod

 

Check mongoDB service status Linux Mint

Check version again:

Now, let’s see what version now we have on our system:

mongo --version

Check MonGo server version

Start with Mongo Command line on Linux mint 18 | 19 | 20

Now we start the database using the command

mongo

• To get the existing database we can use this command:

show dbs

the output will show the three preset databases admin, config, and local.

• To create our database with the command

use yourDbname

• Here we now insert a first data record: The command is:

db.items.insert ({name:“name”})

creates a first data entry.

• With this command:

db.items.find ()

we can check whether the data record with ObjectID is now available.

Again with the command “ show dbs ”, MongoDB will show us not only the three standard databases but also our newly created “ New Database ”.

• To exit, the command line”

exit;

Start with Mongo Command line

 

Ending thoughts:

Both the ways of installing MongoDB are good but we recommend for the second to get the latest version. It is a great alternative to Oracle MySQL and others for enterprises that are dealing with huge data. In addition, the company “Mongo” also offers management tools with which the database operators can monitor the configuration, monitoring, backup, restoration, and updating of MongoDB clusters. This is critical to make the database suitable for the most demanding use cases and organizations with strict SLA (Service Level Agreement) and operational requirements.

 

 

Leave a Reply

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