Part 17 | MongoDB installing, showing database in console | Project E-commerce Application( Part-3)

2 min read 2 hours ago
Published on Dec 15, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

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

  1. Download MongoDB:

  2. 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.
  3. 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.
  4. 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.

Step 2: Access MongoDB in the Console

  1. Open a New Terminal Window:

    • Do not close the terminal running mongod. Instead, open a new terminal or command prompt.
  2. 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
      
  3. 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.
  4. 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.

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.