How to install MongoDB on Debian 9

banner dedicated

In this tutorial, we will explain how to install MongoDB on your Debian 9 Dedicated Server.

Update your server before the installation of MongoDB

apt-get update && apt-get upgrade -y

Install MongoDB

apt-get install mongodb -y

Commands to start/stop MongoDB

systemctl start mongodb
systemctl stop mongodb

Check the version of MongoDB installed

>mongod --version
db version v3.2.11
git version: 009580ad490190ba33d1c6253ebd8d91808923e4
OpenSSL version: OpenSSL 1.0.2l  25 May 2017
allocator: tcmalloc
modules: none
build environment:
    distarch: x86_64
    target_arch: x86_64

Test MongoDB

MongoDB shell version: 3.2.11
connecting to: test
> help                    help on db methods             help on collection methods                    sharding helpers                    replica set helpers
    help admin                   administrative help
    help connect                 connecting to a db help
    help keys                    key shortcuts
    help misc                    misc things to know
    help mr                      mapreduce
    show dbs                     show database names
    show collections             show collections in current database
    show users                   show users in current database
    show profile                 show most recent system.profile entries with time >= 1ms
    show logs                    show the accessible logger names
    show log [name]              prints out the last segment of log in memory, 'global' is default
    use                 set current database                list objects in collection foo { a : 1 } )     list objects in foo where a == 1
    it                           result of the last line evaluated; use to further iterate
    DBQuery.shellBatchSize = x   set default number of items to display on shell
    exit                         quit the mongo shell
> exit

banner dedicated

Colo-Serv Communications has written 32 articles

Premium Dedicated Hosting Services