Install MongoDB 6.0.3 on Ubuntu 22.04
Install MongoDB 6.0.3 on Ubuntu 22.04
Harness the power of MongoDB 6.0.3 on your Ubuntu 22.04 system! This comprehensive guide walks you through the installation process, configuration, and security best practices, ensuring a smooth and secure deployment.
Verify MongoDB Installation
Before you start, check if MongoDB is already installed:
mongod --version
Install MongoDB 6.0.3
Follow these steps to install MongoDB:
-
Import the MongoDB public GPG Key:
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
-
Create a list file for MongoDB:
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
-
Update the package list and install MongoDB:
sudo apt update sudo apt upgrade sudo apt install mongodb-org
-
Verify the installation:
mongod --version
Enable and Start MongoDB
-
Enable MongoDB to start on system boot:
sudo systemctl enable mongod
-
Start MongoDB:
sudo service mongod start
-
Check MongoDB status:
sudo service mongod status
Configure MongoDB
-
Open and edit the MongoDB configuration file:
sudo nano /etc/mongod.conf
-
Make the following changes in the config file:
security: authorization: enabled net: port: 27017 bindIp: 127.0.0.1
-
Check if the port is allowed through the firewall:
sudo ufw status verbose
-
If the port is not allowed, enable it:
sudo ufw allow 27017
-
Restart MongoDB to apply the changes:
sudo service mongod restart
-
Confirm if MongoDB is allowing remote connections:
sudo lsof -i | grep mongo