How To Install MongoDB On Ubuntu

MongoDB is a popular NoSQL database that can be installed on Ubuntu, a popular Linux distribution. To install MongoDB on Ubuntu, you can follow these steps:

  1. Import the MongoDB public key:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
  1. Create a list file for MongoDB:
echo "deb [ arch=amd64,arm64 ] 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 local package database:
sudo apt-get update
  1. Install MongoDB:
sudo apt-get install -y mongodb-org
  1. Start MongoDB:
sudo service mongod start
  1. Verify that MongoDB has started successfully by checking the status of the service:
sudo service mongod status
  1. To access the MongoDB shell, use the following command:
mongo

8.To make MongoDB start automatically on system boot, use the following command:

sudo systemctl enable mongod

Please note that these are general steps and the specific commands may vary depending on your version of Ubuntu and MongoDB. Also, it's recommended to read the MongoDB official documentation for more information.

You can also check out the MongoDB documentation for Ubuntu installation https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

Previous Post Next Post