Part 17 | MongoDB installing, showing database in console | Project E-commerce Application( Part-3)
Table of Contents
Introduction
This tutorial will guide you through the process of installing MongoDB and displaying databases in the console, as demonstrated in the Brototype Malayalam video series on building an e-commerce application. By the end of this tutorial, you'll have a functional MongoDB setup ready for your projects.
Step 1: Install MongoDB
-
Download MongoDB:
- Visit the MongoDB Download Center.
- Select your operating system and download the appropriate installer.
-
Run the Installer:
- Open the downloaded file to start the installation.
- Follow the prompts to complete the installation.
- Choose “Complete” for the setup type to install all features.
-
Set Up MongoDB:
- After installation, create a folder for MongoDB data. Open a terminal or command prompt and run:
mkdir C:\data\db
- This command creates a directory where MongoDB will store its data.
- After installation, create a folder for MongoDB data. Open a terminal or command prompt and run:
-
Start MongoDB:
- In the terminal, navigate to the MongoDB bin directory. For example:
cd "C:\Program Files\MongoDB\Server\<version>\bin"
- Start the MongoDB server with the following command:
mongod
- Ensure that the terminal indicates MongoDB is running without errors.
- In the terminal, navigate to the MongoDB bin directory. For example:
Step 2: Access MongoDB in the Console
-
Open a New Terminal Window:
- Do not close the terminal running
mongod
. Instead, open a new terminal or command prompt.
- Do not close the terminal running
-
Launch MongoDB Shell:
- In the new terminal, navigate to the same bin directory:
cd "C:\Program Files\MongoDB\Server\<version>\bin"
- Start the MongoDB shell by typing:
mongo
- In the new terminal, navigate to the same bin directory:
-
Show Databases:
- To view the databases available, use the command:
show dbs
- This will display a list of all databases currently available in your MongoDB instance.
- To view the databases available, use the command:
-
Create a New Database (Optional):
- You can create a new database by switching to it using:
use <database_name>
- Replace
<database_name>
with your desired database name. This creates the database if it does not already exist.
- You can create a new database by switching to it using:
Conclusion
You've successfully installed MongoDB and accessed the database console. You can now manage your databases directly from the MongoDB shell. As the next step, consider exploring CRUD operations (Create, Read, Update, Delete) within your new database to build out your e-commerce application. For further learning, refer to additional tutorials in the series or join the community for support.