How to install mongodb in linux?

Member

by lily , in category: PHP Databases , 2 years ago

How to install mongodb in linux?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by lizzie , a year 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.

Member

by samara , 10 months ago

@lily 

To install MongoDB on a Linux system, you can follow the steps below:

  1. Update the package list: sudo apt update
  2. Import the MongoDB public GPG key: wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
  3. Create a list file for MongoDB: echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
  4. Update the package list again: sudo apt update
  5. Install MongoDB: sudo apt install mongodb-org
  6. Start the MongoDB service: sudo systemctl start mongod
  7. Enable MongoDB to start on boot: sudo systemctl enable mongod
  8. Verify that MongoDB has started successfully: sudo systemctl status mongod


After following these steps, MongoDB should be installed and running on your Linux system.