DEV Community

Cover image for [Day 5] Installing MongoDB
Wojciech Wernicki
Wojciech Wernicki

Posted on

[Day 5] Installing MongoDB

Hello guys!

After short & unexpected break, I'm back and ready to set up yet another thing on my VPS — today it's a database.

Why MongoDB?

I have two main reasons behind that choice:

  1. I don't have much experience with MongoDB;
  2. Which I want to use with GraphQL, also pretty unknown for me at the moment.

Installing MongoDB

I followed the official tutorial provided by MongoDB, available here. I need to install MongoDB in version 4.0 or above, otherwise, GraphQL won't work. Current documentation for MongoDB suggests installing version 4.4, so I will go with that.

Most important steps of install process:

wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - # add Mongo's key to APT

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list # add MongoDB 4.4 to list of APT sources

sudo apt update # update packages

sudo apt install mongodb # install MongoDB

sudo systemctl start mongod # start MongoDB service

sudo systemctl enable mongod # allow MongoDB to self-start after server is rebooted
Enter fullscreen mode Exit fullscreen mode

After all these steps, MongoDB is installed, running in the background and ready to be started after machine reboot. I checked that by typing in mongo into open SSH console.


That's all for today! In the next post I will talk about how I secured database.

References


Cover image: Photo by Jan Antonin Kolar on Unsplash

Top comments (0)