Step by step guide to install MongoDB on Ubuntu.
First update the packages
$ sudo apt-get update
install the MongoDB package
$ sudo apt install -y mongodb
$ sudo systemctl status mongodb
You should see something like this:
● mongodb.service - An object/document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; disabled; vendor preset:
Active: active (running) since Mon 2019-06-17 20:20:39 IST; 6s ago
Docs: man:mongod(1)
Main PID: 28176 (mongod)
Tasks: 23 (limit: 4915)
CGroup: /system.slice/mongodb.service
└─28176 /usr/bin/mongod --unixSocketPrefix=/run/mongodb --config /etc
To know the status of the MongoDB, use:
$ sudo systemctl status mongodb
To stop the MongoDB server, use:
$ sudo systemctl stop mongodb
To start the MongoDB server, use:
$ sudo systemctl start mongodb
To restart the server, use:
$ sudo systemctl restart mongodb
By default, MongoDB is configured to start automatically when the system is booted. If you want to disable the automatic startup, use:
$ sudo systemctl disable mongodb
To revert back to autostart on system bootup, use:
$ sudo systemctl enable mongodb