How to Install and Set Up MongoDB Database on Windows
Step 1: Download MongoDB
Visit the official MongoDB Download Center and select the Community Server edition.
Choose Windows as the operating system and download the .msi installer.
Step 2: Install MongoDB
Run the .msi installer and follow the on-screen instructions.
In the setup type, select Complete for a full installation.
Choose to install MongoDB as a Service (recommended for easier management).
Ensure "Run MongoDB as a Service" is selected.
Leave the service name as the default (MongoDB).
Set the service to run on Localhost with the default port (27017).
Install MongoDB Compass (optional). This is a GUI tool to interact with the database.
Step 3: Add MongoDB to the System Path
After installation, you need to add MongoDB’s bin folder to your system’s environment variable PATH to use mongo commands from any directory.
Open Control Panel → System and Security → System.
Click Advanced system settings, then go to the Environment Variables button.
In System variables, find Path and click Edit.
Add the path to the MongoDB bin folder (usually C:\Program Files\MongoDB\Server\version\bin).
Step 4: Verify Installation
Open Command Prompt and type mongo --version. You should see the version details of MongoDB.
To start the MongoDB server, type mongod in the command prompt. MongoDB will now be running locally on localhost:27017.
Step 5: Create a Database Directory
By default, MongoDB stores its data in the /data/db directory, but this needs to be created manually.
Open Command Prompt and run:
bash
mkdir C:\data\db
This will create the necessary folder for MongoDB to store your database files.
Step 6: Start the MongoDB Server
In the Command Prompt, run the following command to start the MongoDB server:
bash
mongod
This command will start the MongoDB server and listen for connections.
Step 7: Access MongoDB
Open another Command Prompt window and run:
bash
mongo
This will launch the MongoDB shell where you can start running database commands.
By following these steps, MongoDB will be successfully installed and running on your Windows machine, ready for use in your projects.
Смотрите видео How to Install and Set Up MongoDB on Windows: Step-by-Step Guide for Beginners онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал mrBraveManLabs 06 Октябрь 2024. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 73 раз и оно понравилось 1 посетителям.