To install MongoDB and MongoDB Compass on Ubuntu, follow these steps:
1. Install MongoDB
Step 1: Import the MongoDB public key
First, you need to import the MongoDB public GPG key:
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -Step 2: Create a list file for MongoDB
Create a list file for MongoDB:
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.listStep 3: Update the package list
Update the package list:
sudo apt-get updateStep 4: Install MongoDB
Install the latest stable version of MongoDB:
sudo apt-get install -y mongodb-orgStep 5: Start MongoDB
Start the MongoDB service:
sudo systemctl start mongodStep 6: Enable MongoDB to start on boot
Enable MongoDB to start on boot:
sudo systemctl enable mongodStep 7: Verify MongoDB installation
Check the status of the MongoDB service to ensure it is running:
sudo systemctl status mongod2. Install MongoDB Compass
Step 1: Download MongoDB Compass
Download the MongoDB Compass .deb package from the official MongoDB website:
wget https://downloads.mongodb.com/compass/mongodb-compass_1.36.2_amd64.debStep 2: Install MongoDB Compass
Install the downloaded .deb package:
sudo dpkg -i mongodb-compass_1.36.2_amd64.debIf you encounter any dependency issues, run:
sudo apt-get install -fStep 3: Launch MongoDB Compass
You can launch MongoDB Compass from the terminal or by searching for it in your application menu:
mongodb-compass3. Verify Installation
MongoDB: You can verify the MongoDB installation by connecting to the MongoDB shell:
mongo --versionYou can also connect to the MongoDB server using the MongoDB shell:
mongo