/* 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: "[email protected]", age: 25 },
{ name: "Vishal", email: "[email protected]", age: 30 }
])
It creates a users collection with two documents.
*/