how to install mongo db code example

Example 1: how to install mongodb in linux

How To Install MongoDB on Ubuntu 18.04 through command line :

Step 1Installing MongoDB

$ curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -

$ apt-key list

$ sudo apt update

$ sudo apt install mongodb-org



Step 2Starting the MongoDB Service and Testing the Database

Run the following systemctl command to start the MongoDB service:

$ sudo systemctl start mongod.service

$ sudo systemctl status mongod 
          
$ sudo systemctl enable mongod

$ mongo --eval 'db.runCommand({ connectionStatus: 1 })'

Example 2: mongo install

sudo apt install mongodb-clients

Example 3: install mongodb 2018 instructions

mongo --version

Example 4: install mongodb on mac

//be sure you have GNU's GCC:
brew install gcc

Example 5: install mongodb 2018 instructions

vim .bash_profile