InstallConfigMongoDB
How to Install MongoDB 6.0.3 on Ubuntu 22.04​
- Verify MongoDb Installed or Not
mongod --version
- Install MongoDB 6.0.3 on Ubuntu 22.04
- Installation Process depends on MongoDB Version and Ubuntu Version
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
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
sudo apt update
sudo apt upgrade
sudo apt install mongodb-org
- Verify MongoDb Installed or Not
mongod --version
- Enable MongoDB to start at system startup
sudo systemctl enable mongod
- Start MongoDB
sudo service mongod start
- Check MongoDB Status
sudo service mongod status
How to Configure MongoDB​
- Open and Edit MongoDB config file
sudo nano /etc/mongod.conf
- Make below changes in config file
security:
authorization: enabled
net:
port: 27017
bindIp: 127.0.0.1
- Check Port is Allowed through Firewall
sudo ufw status verbose
- If Port is not Allowed then Allow it through Firewall
sudo ufw allow 27017
- Restart MongoDB
sudo service mongod restart
- Confirm if MongoDB is allowing remote connections
sudo lsof -i | grep mongo