Setup MongoDb
To set up MongoDB on Ubuntu, follow these steps:
-
Visit the MongoDB website for detailed instructions on installing MongoDB.
-
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
-
Verify that MongoDB has started successfully by running the following command:
sudo systemctl status mongod
-
If you want MongoDB to start automatically after a system reboot, run the following command:
sudo systemctl enable mongod
-
To stop MongoDB, use the following command:
sudo systemctl stop mongod
-
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.