MongoDB on Linux Mint
MongoDB is an open-source cross-platform NoSQL database solution. As it’s a NoSQL database, it’s free from the restricted nature of the traditional databases (for example, MySQL), offering more flexibility for storing data. MongoDB can also be treated as a file storage solution! MongoDB offers efficient scaling, thanks to its sharding feature.
There are two editions of MongoDB available to the customers – the Community and Enterprise version. Now, for general users, the MongoDB Community edition will be enough for testing/developing purposes. However, for large-scale implementation, it’s a good idea to get the Enterprise one. MongoDB Enterprise comes with additional features like customer support, Kubernetes integration, faster memory performance, certification, etc. Check out MongoDB Enterprise Advanced.
In this article, however, I’ll be showcasing how to install and use the MongoDB Community edition.
Install MongoDB on Linux Mint
There are multiple ways we can install MongoDB. Because of its popularity, it’s already a part of the Ubuntu package servers. Linux Mint, being an Ubuntu derivative, can directly grab MongoDB from the package server. However, the official recommendation of MongoDB is to use its own repository for installing the database software.
Ready? Let’s jump right into it!
Install MongoDB from Ubuntu package server
MongoDB is directly available from the Ubuntu package server. All you need is to tell APT to grab and install the mongodb package. Although it’ll work just fine, according to official MongoDB documentation, it’s not recommended method. Follow it at your own responsibility.
First, fire up a terminal and update the APT cache.
Now, tell APT to install MongoDB.
Install MongoDB from MongoDB repo
MongoDB officially offers repo for Ubuntu, Debian, SUSE Linux, and Amazon. MongoDB officially recommends this method of installing MongoDB. This makes sure that you’re always using the latest version. Linux Mint is Ubuntu-based, so the Ubuntu repo will work just fine.
Note: The repo is version-dependent. This method will showcase the installation of the current latest MongoDB stable version (MongoDB 4.2). For other versions, check out the MongoDB installation document.
Fire up a terminal and start running the following commands. First, let’s check out if GnuPG is installed. GnuPG comes preinstalled with Linux Mint. However, if it was uninstalled previously, then this command will install it right away.
Now, add the public GPG key of MongoDB repo.
APT is ready to communicate with the MongoDB repo. Add the MongoDB repo in the list of APT package servers.
mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
Update the APT cache.
The MongoDB repo is added successfully. Now, tell APT to install MongoDB. The package name is mongodb-org. Note that mongodb is from Ubuntu repo whereas mongodb-org is from MongoDB repo.
Using MongoDB
Once the installation is complete, let’s make sure that MongoDB is running. Run this command in the terminal.
The command threw some error. It’s because MongoDB, by default, doesn’t start with boot. To fix this, run the next two command. Essentially, we’re telling systemctl to start and enable MongoDB service at boot.
$ sudo systemctl enable mongod
Check MongoDB once again.
Voila! MongoDB is running perfectly! It’s the MongoDB shell that’s running. It serves as the MongoDB control center. MongoDB has its own commands and functions. The following command will print a shortlist of available commands and functions.
Final thoughts
MongoDB is a powerful database software. It’s even incorporated by Google, Facebook, PayPal, EA, Adobe, eBay etc. giants. Check out companies using MongoDB. That, by itself, is a testimony of the power of MongoDB.
This article just discusses how to install MongoDB. There is a lot to learn about it. You can find plenty of tutorials on the internet on getting started with MongoDB. Check out this beginner’s guide to MongoDB.
Enjoy!
from Linux Hint https://ift.tt/2Y7L34y
0 Comments