You can see detailed instruction on how to install on MongoDB web site.
First add key
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
For Debian 8, run
echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/4.0 main" > /etc/apt/sources.list.d/mongodb-org-4.0.list
For Debian 9, run
echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 main" > /etc/apt/sources.list.d/mongodb-org-4.0.list
Now install mongoDB with
apt-get update apt-get install -y mongodb-org
Once installed, you can check version with
root@ip-172-31-25-155:~# mongod --version db version v4.0.4 git version: f288a3bdf201007f3693c58e140056adf8b04839 OpenSSL version: OpenSSL 1.1.0f 25 May 2017 allocator: tcmalloc modules: none build environment: distmod: debian92 distarch: x86_64 target_arch: x86_64 root@ip-172-31-25-155:~#
Enable MongoDB start on boot
systemctl enable mongod
To start/stop mongodb
systemctl start mongod systemctl stop mongod
Leave a Reply