MongoDB is an open-source NoSQL-based DBMS, which stores and retrieves data as a key-value pair but the value part is stored as a document in JSON/XML format. This post highlights the steps to install MongoDB Tools on your Operating Systems(OS) such as Windows, macOS, and many more. Before you proceed forward, let’s get a basic understanding of MongoDB and MongoDB Database Tools.
Introduction to MongoDB
MongoDB is a document-oriented NoSQL database designed for storing and analyzing large amounts of data. It stores data as Collections and documents rather than tables with rows and columns, as opposed to typical Relational Databases. The Collections are made up of a number of documents, each of which contains key-value pairs, which are the fundamental units of data.
The use of sharding in MongoDB allows for horizontal scalability. That is, it uses the Shard Key to distribute data across several servers. Every MongoDB Cluster shard holds a subset of the data, allowing it to serve as a standalone database. This combination of comprehensive databases allows for the proper administration of growing volumes of data with little downtime. MongoDB’s stronger concurrency controls and locking mechanisms allow it to reliably manage several concurrent read and write requests for the same data.
Explore more about MongoDB here.
Introduction to MongoDB Database Tools
MongoDB Database Tools are a bunch of command-line utilities that are used for executing various operations on your MongoDB installation tools. These tools can be further divided based on their utility, so there are Data Import/Export tools, Diagnostic Tools, Binary Import/Export, and GridFS Tools, etc.
Till MongoDB version 4.2, these tools were packaged along with the MongoDB server itself, but from MongoDb version 4.4 these tools are released and versioned separately. The first independent version was 100.0.0. The latest version of MongoDB tools is 100.5.1 which is compatible with MongoDB server 5.0/4.4/4.2/4.0.
Types of MongoDB Database Tools
In this post, you will discuss how to install MongoDB Tools in the Operating System of your choice, but before that let’s delve into a small introduction of these tools.
The MongoDB Database Tools consist of the following binaries:
Data Import/Export tools
- mongoimport: Imports content into mongod, from an Extended JSON/CSV/TSV export file.
- mongoexport: Produces a JSON or CSV export of the data stored in a mongod instance.
Binary Import / Export
- mongodump: Creates a binary export of the data stored in a mongod database.
- mongorestore: Restores data from a mongodump database dump into a mongod or mongos.
- bsondump: Converts BSON dump files into JSON for further use by mongoexport OR other tools
GridFS Tools
- mongofiles: They are used for manipulating GridFS object files.
For storing objects internally, MongoDB uses the Binary JSON or BSON format, where the data is decomposed into binary format to enable faster reads by eliminating the need of parsing JSON with every read request.
But BSON has a size limit of 16MB per file, so for files that exceed this 16MB limit, the GridFS protocol is used to divide a file into parts/chunks, and stores each chunk as a separate document.
As you can see these tools are essential in enabling proper usage of your MongoDB. Since these tools interact extensively with the underlying file system and hence the operating system (OS), they are installed differently on different OS.
Hevo Data, a No-code Data Pipeline, helps load data from any data source such as Databases, SaaS applications, Cloud Storage, SDK,s, and Streaming Services and simplifies the ETL process. It supports 150+ Data Sources such as MongoDB, including 40+ Free Sources. It is a 3-step process by just selecting the data source, providing valid credentials, and choosing the destination.
Hevo loads the data onto the desired Data Warehouse/destination in real-time and enriches the data and transforms it into an analysis-ready form without having to write a single line of code. Its completely automated pipeline, fault-tolerant, and scalable architecture ensure that the data is handled in a secure, consistent manner with zero data loss and supports different forms of data. The solutions provided are consistent and work with different BI tools as well.
GET STARTED WITH HEVO FOR FREE
Install MongoDB Tools on Linux
Here we will discuss the latest version at the time of writing this post, which is 100.5.1 and it’s compatible with the following Unix-based (x86_64 architecture) systems.
- Amazon Linux 2 and 2013.03+
- Debian 10, 9, and 8
- RHEL / CentOS 8, 7, and 6
- SUSE 12
- Ubuntu 20.04, 18.04, 16.04, and 14.04
You can install the MongoDB Database Tools on Linux via the following methods:
1) Linux: Install MongoDB Tools via DEB package
Step 1: To install MongoDB Tools, download the MongoDB Database Tools .TGZ archive OR use your Linux distribution’s package manager like apt-get/yum/dpkg/Dandified yum/gentoo etc., to get the appropriate package like .rpm/.deb/.tgz.
You can use wget or curl to directly download the deb package from MongoDB Command Line Database Tools Download page (https://www.mongodb.com/try/download/database-tools) .
Step 2: Next, either move the downloaded package to the directory of your choice or navigate to the directory containing the package, and run the following command:
sudo apt install ./mongodb-database-tools-*-100.5.1.deb
Using “./” will instruct apt to look for the package in the current directory instead of any remote repos.
Step 3: Include this directory where you just installed mongodb-database-tools, in your PATH directive. You can move the extracted mongodb-database-tools directory to /usr/local/bin.
One of the above 2 steps will ensure that you can run the tools from any directory on your OS system.
Step 4: Run the tools from the command line
2) Linux: Install MongoDB Tools via RPM package
Step 1: Use wget or curl to directly download the rpm package from MongoDB Command Line Database Tools Download page (https://www.mongodb.com/try/download/database-tools) .
Step 2: Next, either move the downloaded package to the directory of your choice or navigate to the directory containing the package, and run the following command:
sudo yum install -y mongodb-database-tools-*-100.5.1.rpm
Step 3: Include this directory where you just installed mongodb-database-tools, in your PATH directive. This will ensure that you can run the tools from any directory on your OS system.
Step 4: Run the tools from the command line.
3) Linux: Install MongoDB Tools via TGZ package
Step 1: Use wget or curl to directly download the tgz archive from the MongoDB Command Line Database Tools Download page (https://www.mongodb.com/try/download/database-tools).
Step 2: Next, either move the downloaded package to the directory of your choice or navigate to the directory containing the package, and run the following command to extract the TGZ file :
tar -zxvf mongodb-database-tools-*-100.5.1.tgz
Step 3: Include this directory where you just installed mongodb-database-tools, in your PATH directive.
OR
You can move the extracted mongodb-database-tools directory to /usr/local/bin. This will ensure that you can run the tools from any directory on your OS system.
Step 4: Run the tools from the command line.
Install MongoDB Tools on macOS
You can either install mongodb-database-tools via Homebrew OR by downloading the package directly. If you installed the MongoDB server via Homebrew, then MongoDB Database Tools will be installed automatically with it.
To check if MongoDB Database Tools is already on your macOS system, run the following command:
brew list | grep mongodb-database-tools
Step 1: Use the following command to install MongoDB Homebrew formulae, which will install both MongoDB server as well as MongoDB Database Tools.
brew tap mongodb/brew
Use wget or curl to directly download the tgz archive from the MongoDB Command Line Database Tools Download page (https://www.mongodb.com/try/download/database-tools) .
If you want to install the MongoDB community edition as well as brew install mongodb-community+mongodb compass, run the following command:
brew install mongodb-community
Step 2: In case you already have the MongoDB server running OR already have the MongoDB shell, and just want to install MongoDB tools only, run the following command:
brew install mongodb-database-tools
Step 3: Next, either move the downloaded package to the directory of your choice or navigate to the directory containing the package, and run the following command to extract the TGZ file:
tar -zxvf mongodb-database-tools-*-100.5.1.tgz
Step 4: To install a specific MongoDB version, use the following command:
brew install mongodb-community@4.0
Step 5: After installing the MongoDB community version, it will contain some important files as following
- A Configuration File: /opt/homebrew/etc/mongod.conf [ if running Apple M1 Processor] OR /usr/local/etc/mongod.conf [ if running Intel Processor]
- A Data Directory Path: /opt/homebrew/var/mongodb OR /usr/local/var/mongodb
- A Log Directory Path: /opt/homebrew/var/log/mongodb OR /usr/local/var/log/mongodb
Step 6: If you receive a security error when starting mongod indicating that the Developer could not be identified or verified, do the following to grant mongod access to run:
- Navigate to System Preferences > Security and Privacy pane.
- Under the General tab, you will see either of the 2 buttons to the right of the message about mongod, labeled either Open Anyway or Allow Anyway, depending on your version of macOS.
- Click Open Anyway / Allow Anyway.
Step 7: In the future, use the following command to update your Database Tools version:
brew upgrade mongodb-database-tools
Step 8: Run the tools from the macOS command line.
Install MongoDB Tools on Windows
You can install MongoDB Tools on Windows using the following methods:
1) Windows: Install MongoDB Tools via MSI Installer
Step 1: From the Database Tools Download page (https://www.mongodb.com/try/download/database-tools),
select Windows x86_64 Platform and the MSI package, to download it.
Step 2: Just double click the MSI installer and it will install the tools on your system. If needed, specify an installation directory of your choice during the installation.
Step 3: Make the DB Tools available in your PATH. Unless you add the file path location of MongoDB Database Tools to your PATH variable, you can run it only from the installation directory.
To make the mongodb-database-tools available from anywhere on your system:
- Go to Control Panel –> System and Security category –> System.
- Then click Advanced system settings, the System Properties modal dialogue will start displaying.
- Choose Environment Variables.
- Next, select Path and click Edit. The environment variable will be displayed.
- Add file path location of MongoDB Database Tools installation directory.
- To save your changes, click OK.
Step 4: Run the MongoDB Database Tools from the command line.
2) Windows: Install MongoDB Tools via ZIP Installer
Step 1: From the Database Tools Download page (https://www.mongodb.com/try/download/database-tools), select Windows x86_64 Platform and the ZIP package, to download it.
Step 2: Double click the ZIP package and unpack it in the directory of your choice on your computer’s filesystem.
Step 3: Make the DB Tools available in your PATH.
To make the mongodb-database-tools available from anywhere on your system follow the steps mentioned in previous method’s Step 3.
Step 4: Run the MongoDB Database Tools from the command line.
Conclusion
In a nutshell, we have discussed how to install MongoDB Tools on your system and some related settings involved. Moreover, you also understood the various types of MongoDB Database Tools.
However, as a Developer, extracting complex data from a diverse set of data sources like Databases, CRMs, Project management Tools, Streaming Services, Marketing Platforms to your MongoDB Database can seem to be quite challenging. This is where a simpler alternative like Hevo can save your day! Hevo Data is a No-Code Data Pipeline that offers a faster way to move data from 150+ Data Sources such as MongoDB and other 40+ Free Sources, into your Data Warehouse to be visualized in a BI tool. Hevo is fully automated and hence does not require you to code.
VISIT OUR WEBSITE TO EXPLORE HEVO
FAQ
How to install MongoDB tools in Linux?
To install MongoDB Database Tools (like mongodump
, mongoimport
, etc.) on Linux:
1. Add MongoDB’s official key:
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
2. Add the MongoDB repository (Debian/Ubuntu):
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/debian $(lsb_release -cs)/mongodb-org/6.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
3. Update your package list:
sudo apt update
4. Install MongoDB tools:
sudo apt install -y mongodb-database-tools
What are the tools required for MongoDB?
Some key MongoDB tools include:
mongodump: For backing up MongoDB data.
mongorestore: To restore MongoDB data.
mongoexport: For exporting data from MongoDB in JSON or CSV format.
mongoimport: To import data from JSON, CSV, or TSV.
mongostat: Provides MongoDB server status.
mongotop: Displays MongoDB usage statistics.
How to install MongoDB by terminal?
To install MongoDB on Linux using the terminal:
1. Import MongoDB GPG Key:
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
2. Add the MongoDB repository:
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. Update package list:
sudo apt update
4. Install MongoDB:
sudo apt install -y mongodb-org
5. Start MongoDB:
sudo systemctl start mongod
MongoDB should now be installed and running on your Linux system.
Pratik Dwivedi is a seasoned expert in data analytics, machine learning, AI, big data, and business intelligence. With over 18 years of experience in system analysis, design, and implementation, including 8 years in a Techno-Managerial role, he has successfully managed international clients and led teams on various projects. Pratik is passionate about creating engaging content that educates and inspires, leveraging his extensive technical and managerial expertise.