Skip to content

Instantly share code, notes, and snippets.

@dipanshuchaubey
Created June 17, 2019 15:01
Show Gist options
  • Save dipanshuchaubey/e1b808b99b49acc84d8e0f60d0492bd5 to your computer and use it in GitHub Desktop.
Save dipanshuchaubey/e1b808b99b49acc84d8e0f60d0492bd5 to your computer and use it in GitHub Desktop.
Step by step guide to install MongoDB on Ubuntu

Install MongoDB on Ubuntu

Step by step guide to install MongoDB on Ubuntu.

1 > Installing MongoDB

First update the packages

$ sudo apt-get update

install the MongoDB package

$ sudo apt install -y mongodb

2 > Checking the Service and Database

$ 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

3 > Managing the MongoDB Service

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

License

MIT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment