/* Steps to Set Up MongoDB
Step 1: Install MongoDB:
Download MongoDB from the official website. https://www.mongodb.com/try/download/...
Step 2: Add to PATH Environment Variable:
1. Locate mongod.exe file present in C:\Program Files\MongoDB\Server\8.0\bin and copy the
path to bin folder.
2. Open the Start menu and search for Environment Variables.
Click Edit the system environment variables.
In the System Properties window, click Environment Variables.
Under System variables, find and select Path, then click Edit.
Click New and paste the path
Click OK to save.
3. Create the Data Directory:
Open the terminal or Command Prompt.
Create the required directory by running: mkdir \data\db
Start MongoDB Server:
Open a terminal or command prompt.
Run the following command to start the MongoDB server: mongod
This will start the MongoDB server on the default port (27017).
Step 3: Set Up a Database:
Open another terminal or command prompt.
Run the following command to start the MongoDB shell: mongosh
Note: If mongo shell is not installed, download it seperately from official URL "https://www.mongodb.com/try/download/..."
and install it seperately
Add to PATH Environment Variable:
1. Locate mongosh.exe file present in C:\Program Files\MongoDB\Server\mongosh-2.3.7-win32-x64\bin and copy the
path to bin folder.
2. Open the Start menu and search for Environment Variables.
Click Edit the system environment variables.
In the System Properties window, click Environment Variables.
Under System variables, find and select Path, then click Edit.
Click New and paste the path
Click OK to save.
3. Close and reopen your terminal or PowerShell, then try running: mongosh
To create a new database, use the following command: use myTestDb
Replace myTestDb with the name of your database.
Step 4: Go to database with the following url:
mongodb://localhost:27017/
Step 5: Insert Initial Data (Optional):
In the MongoDB shell, you can insert some initial data into a collection:
db.users.insertMany([
{ name: "Kashish", email: "alice@example.com", age: 25 },
{ name: "Vishal", email: "bob@example.com", age: 30 }
])
It creates a users collection with two documents.
*/
On this page of the site you can watch the video online #24 MongoDB Installation and Setup Step-by-Step | Windows Setup Tutorial with a duration of hours minute second in good quality, which was uploaded by the user Web Journey with Kashish 19 December 2024, share the link with friends and acquaintances, this video has already been watched 66 times on youtube and it was liked by 8 viewers. Enjoy your viewing!