Table of Content
In some cases, you might need to work with older versions of MongoDB for testing or legacy purposes. This tutorial guides you through the process of installing an older version of MongoDB Shell on a Windows machine and configuring it to run as a service automatically on boot.
- Windows operating system - Basic familiarity with the Windows command line
- Visit the MongoDB archive releases page (https://www.mongodb.com/download-center/community/releases/archive) to download the desired version. For this tutorial, we'll use version 4.2.14. - Navigate to the Windows section and download the ZIP file for version 4.2.14.
- After downloading, extract the contents of the ZIP file. - Locate the `bin` folder within the extracted files. - Move the `bin` folder to `C:\Program Files\MongoDB\mongoshell\`.
- Open the Environment Variables settings on your Windows machine. - Add `C:\Program Files\MongoDB\mongoshell\` to the `PATH` variable. - Save the changes.
- Create two directories: - `C:\data\db` (for database files) - `C:\data\log` (for log files)
- Create a configuration file named `mongod.cfg` in a convenient location. - Add the following configuration settings to `mongod.cfg`:
systemLog:
destination: file
path: c:\data\log\mongod.log
storage:
dbPath: c:\data\db
- Restart your computer to apply the environment variable changes.
- Open Command Prompt with administrator privileges. - Execute the following command:
mongod --config "C:\path\to\mongod.cfg" --install
Replace `"C:\path\to\mongod.cfg"` with the actual path to your configuration file.
- After installing MongoDB as a service, start the service by running:
net start MongoDB
- Confirm that the MongoDB service is running properly by checking for its status. - You can use MongoDB Compass or the command line to connect and interact with the MongoDB instance.
Congratulations! You have successfully installed an older version of MongoDB Shell on your Windows machine and configured it to run as a service automatically on boot. You can now use this setup for testing or working with legacy databases.