2️⃣Install MongoDB
Use this tutorial to install MongoDB 6.0 Community Edition on LTS (long-term support) releases of Ubuntu Linux using the apt
package manager.
Type the command below on the terminal.
sudo apt-get install gnupg curl
On your terminal, please copy and paste below code.
curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \
sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg \
--dearmor
Now copy and paste below code to the terminal. please use the code according to your operating system.
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list
Now update the repository.
sudo apt-get update
Now Install the Mongodb.
sudo apt-get install -y mongodb-org
Now start the mongodb service to your server.
sudo systemctl start mongod
Type this command to start mongodb on every start on your server.
sudo systemctl enable mongod
Check whether the mongodb service is running or not.
sudo systemctl status mongod
This is show a success message like below.
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor prese>
Active: active (running) since Mon 2023-08-07 09:38:45 UTC; 6s ago
Docs: https://docs.mongodb.org/manual
Main PID: 11249 (mongod)
Memory: 72.5M
CPU: 662ms
CGroup: /system.slice/mongod.service
└─11249 /usr/bin/mongod --config /etc/mongod.conf
That's it. Mongodb is now installed on your system.
Last updated