Hey there developers! 👋🏾
If you're a fan of using MongoDB for your database needs, you may have noticed that the latest version 6 no longer comes bundled with mongo.exe But no worries, I'm here to guide you through the process of downloading and installing MongoDB and its shell, Mongosh for mongoDB to work.
First off,
head on over to the official MongoDB website,
and download the version of MongoDB that's right for you.
Make sure to choose the version compatible with your operating system.
Once you have the downloaded file, let's get started with the installation process:
Step 1: Install MongoDB
Double-click on the downloaded file to open the installer.
Follow the instructions on the screen to complete the installation process.
Once the installation is complete, you'll need to run the mongod process to start the MongoDB server. To do this, open up a terminal or command prompt and navigate to the bin directory within the MongoDB installation folder.
Mine was "C:\Program Files\MongoDB\Server{version_number}\bin".
Replace "{version_number}" with the version of MongoDB you have installed. the current version as at writing was 6.0
- Then run the following command:
mongod.exe --dbpath "C:\data\db"
or
mongod --dbpath "C:\data\db"
This command will start the MongoDB server and use the directory "C:\data\db"(data directory with db directory inside) as the data directory for the server. If the directory does not exist, It will create it before running the command "mongod.exe" or "mongod".
you should see some output in the terminal indicating that it's running.
Note: Keep the Command Prompt or PowerShell window open and running
Step 2: Install Mongosh
- Head over to the Mongosh download page
- Download the zip file for your operating system.
Extract the contents of the zip file to the bin directory within the MongoDB installation folder.
Copy the Contents in the just zipped bin's folder and paste it in the mongoDB bin's folder.
Open up a terminal or command prompt and navigate to the bin directory within the MongoDB installation folder.
To start using Mongosh, run the following command:
mongosh
And that's it!
You should now be able to start working with your MongoDB database using the Mongosh shell.
So there you have it, a simple and straightforward guide on how to download and install MongoDB and Mongosh. Happy coding!"
Top comments (0)