02 Mar 2023 15:38:53 Posted By: Arvan Apriyana
MongoDB is a popular NoSQL database that is known for its flexibility and scalability. It is widely used by developers for building modern applications due to its powerful query language and dynamic schema. In this article, we will guide you through the steps to install MongoDB on Linux.
Before installing MongoDB, it is recommended to update the package repository on your Linux machine to ensure that you have access to the latest packages. To do this, open the terminal and run the following command:
sudo apt-get update
Once the package repository is updated, you can install MongoDB by running the following command:
sudo apt-get install mongodb
This will download and install MongoDB on your Linux machine.
After installing MongoDB, you need to start the MongoDB service. To do this, run the following command:
sudo systemctl start mongodb
This will start the MongoDB service.
To ensure that MongoDB starts automatically when your Linux machine is rebooted, you need to enable it to start on boot. To do this, run the following command:
sudo systemctl enable mongodb
To verify that MongoDB is installed and running properly on your Linux machine, run the following command:
mongo --eval 'db.runCommand({ connectionStatus: 1 })'
If MongoDB is installed and running properly, you should see the following output:
{
"authInfo" : {
"authenticatedUsers" : [ ],
"authenticatedUserRoles" : [ ]
},
"ok" : 1
}
Congratulations! You have successfully installed MongoDB on your Linux machine. MongoDB is now ready to use, and you can start building modern applications using this powerful NoSQL database. We hope that this step-by-step guide has been helpful for you to install MongoDB on Linux.