Skip to main content

Setup MongoDb

To set up MongoDB on Ubuntu, follow these steps:

  1. Visit the MongoDB website for detailed instructions on installing MongoDB.

  2. Start MongoDB by running the following command:

    sudo systemctl start mongod

    If you encounter an error like Failed to start mongod.service: Unit mongod.service not found, run the following command before starting MongoDB again:

    sudo systemctl daemon-reload
  3. Verify that MongoDB has started successfully by running the following command:

    sudo systemctl status mongod
  4. If you want MongoDB to start automatically after a system reboot, run the following command:

    sudo systemctl enable mongod
  5. To stop MongoDB, use the following command:

    sudo systemctl stop mongod
  6. If you need to restart MongoDB, run the following command:

    sudo systemctl restart mongod

By following these steps, you will be able to set up and manage MongoDB on your Ubuntu system effectively.