Install MongoDB Community Edition

Install MongoDB Community Edition in Ubuntu

Instructions for installing mongodb-org package and not unofficial mongodb package provided by Ubuntu.

  1. Import Public Key

wget -qO – https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add –

2. Identify Ubuntu Version

lsb_release -dc

3.Create the mongodb-org-4.4.list file for Ubuntu 18.04 (Bionic)

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

4. Reload local database package

sudo apt-get update

5. Install latest version of MongoDB

sudo apt-get install -y mongodb-org

6. Identify init system

ps –no-headers -o comm 1

6.1 for systemd systems

sudo systemctl start mongod

6.2 for System V init

sudo service mongod start

 

MongoDB File Locations:

/var/lib/mongodb –> data directory

All in One WordPress Hosting Starts at 30$ per month
All in One WordPress Hosting
WordPress
High optimized WordPress hosting, secure firewall, HTTPS, Backup, hack-fix guarantee and many others at 30$ per month

/var/log/mongodb –> log directory

/etc/mongod.conf –> configuration file, restart is required if any change is made

 

Commands to start/stop/restart/status

sudo systemctl start mongod

sudo systemctl stop mongod

sudo systemctl restart mongod

sudo systemctl status mongod