How to install mongodb in linux?

Member

by lily , in category: PHP Databases , 9 months ago

How to install mongodb in linux?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lizzie , 3 months ago

@lily 

To install MongoDB on a Linux system, you can use the following steps:

  1. Import the public key used by the package management system:
1
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4


  1. Create a list file for MongoDB:
1
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list


  1. Reload the package database:
1
sudo apt-get update


  1. Install the MongoDB packages:
1
sudo apt-get install -y mongodb-org


This will install the latest stable version of MongoDB.

  1. Once the installation is complete, start the MongoDB service with the following command:
1
sudo service mongod start


  1. You can check the status of the MongoDB service with the following command:
1
sudo service mongod status


  1. To ensure that MongoDB starts automatically when the system restarts, use the following command:
1
sudo systemctl enable mongod


That's it! You have now installed MongoDB on your Linux system.