How to install MongoDB 7.0 on Windows Server 2022
This guide provides all the steps needed to install MongoDB 7.0 on Windows Server 2022|2019|2016. But before we plunge in, we need to discuss a few concepts.
Databases play a vital role in many organizations in this digital era where data has become the lifeline of most businesses. They serve as the backbone for storing, managing, and organizing data. The critical part is choosing the right database for your business.
Normally, databases are divided into two broad categories i.e. relational and non-relational databases. These two are distinct in the way data is stored and retrieved. In relational databases, data is stored in structured tables with predefined schemas while in non-relational, data is stored in key-value pairs, column-family stores, documents, or graphs.
MongoDB is one of the top non-relational databases that provides a modern and dynamic approach to data management. This cross-platform database is developed and maintained by MongoDB Inc. By offering a unique document-oriented architecture, MongoDB users benefit from the flexible schema design that curbs all the issues revolving around data storage, retrieval, and manipulation. In addition to that, MongoDB provides high performance and scalability which is required when dealing with the diverse requirements of modern enterprises.
This year, MongoDB has made another release, MongoDB 7.0. This version comes with a lot of features and improvements from its predecessor, MongoDB 6.0. The improvements in MongoDB 7.0 are centered on 4 areas i.e. migrations, developer experience, performance, and security.
The key improvements in MongoDB 7.0 are:
- Empowered Querying: For developers using MongoDB 7.0, querying data becomes more potent. The update brings enhanced tools for handling change streams, which are used to monitor data changes and manage large documents. Introducing new tools like bitwise and percentile operators makes data querying more efficient and accurate. Moreover, users can execute swift updates and deletions on collections that store time-evolving data, offering them greater control.
- Streamlined Migration: Simplifying the process of data movement between clusters, MongoDB 7.0 introduces the Cluster-to-Cluster Sync feature. This functionality streamlines the synchronization of data across different segments of your system, ensuring a smoother and more organized transition. With Cluster-to-Cluster Sync, data management becomes notably easier compared to older, more convoluted methods.
- Enhanced Security: Another robust security feature in MongoDB 7.0 is the Queryable Encryption, underlining its commitment to safeguarding data. This innovative feature empowers users to keep their vital data encrypted, while still allowing them to perform queries on it without compromising sensitive information.
- Optimized Performance: MongoDB 7.0 steps up its performance game with a range of exciting enhancements. The system now employs smarter query execution strategies, accelerates the movement of data chunks within expansive clusters, and introduces a new parameter to handle extensive data sets with exceptional efficiency. Importantly, as your cluster grows, you can trust MongoDB to handle chunk management seamlessly, eliminating the complexities associated with managing numerous small data portions.
Below are the steps to install MongoDB 7.0 on Windows Server 2022|2019|2016.
Requirements
MongoDB 7.0 supports 64-bit versions of Windows on x86_64 architecture:
- Windows Server 2022
- Windows Server 2019
- Windows Server 2016
Download MongoDB 7.0 Windows Installer
We will start by downloading the MongoDB Community .msi installer from the MongoDB Download Center. On the page, select the Version, platform, and package:
Once downloaded, proceed with the below step.
Run MongoDB 7.0 Installer on Windows
To run the installation, navigate to the directory where you downloaded the installer. Double-click on it to start the installation.
Proceed as shown.
Agree to the license terms.
Select the type of installation you want. For this case, we will proceed with the Complete installation.
You need to check the box to install MongoDB as a service and set it to run as a network service.
We will also install MongoDB compass which makes the management of the instance easier.
Start the installation, sit back, and wait for the installation to happen.
Once complete, you will see this. MongoDB compass will be launched and ready for a connection.
Connect and Use MongoDB 7.0 on Windows
Now using MongoDB compass, you can make a connection to the locally installed MongoDB as shown.
If all is okay, you should see this:
You can now create a database on MongoDB and add a collection as shown.
Proceed and add the desired data to the collection.
You can also access and use the MongoDB shell as shown.
You can create an admin user with a password using the Mongo Shell:
use admin
db.createUser(
{
user: "adminuser",
pwd: passwordPrompt(), // or cleartext password
roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
}
)
Sample Output:
Set the desired password for the admin user.
Configure MongoDB 7.0 on Windows
Currently, MongoDB can only be accessed on localhost and has no security enabled. Just like on Unix systems, there is a configuration file used by MongoDB. This configuration file is located at C:\Program Files\MongoDB\Server\7.0\bin
Navigate to this path and open the mongod.cfg file for editing. You can use Notepad to edit it. In the file, you can make the below changes:
- Enable Remote Access
To allow the service to be accessed remotely, make the below adjustment:
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
- Enable Password Authentication
To enable password authentication, modify the line as shown:
security:
authorization: enabled
Once the changes have been made, save the file and restart the service. Launch services and locate the MongoDB service as shown.
Once restarted, allow the service through the firewall. Launch the Windows Firewall and go to advanced settings.
We need to add a new inbound rule for MongoDB. Here. we will use the port.
Provide the MongoDB port and protocol as shown.
Allow the connection, then proceed and add the connection name for the rule to be added.
Test Remote Connection
Once created, you can test the connection remotely from a MongoDB client. For example:
mongosh -u <username> -p --authenticationDatabase admin --host <remote-ip> --port <port>
For example:
Summary
That marks the end of this guide on how to install MongoDB 7.0 on Windows Server 2022. Now you can enjoy the awesomeness provided by this new MongoDB release. I hope this was informative.