Install MongoDB 4 on Debian 9

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

Advertisement

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
Add a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Advertisement