You can have many ways to install mongodb on linux. But I prefer to install the release from official resource.

Here are my steps to install mongodb 4.0 on ubuntu 18.04 system.

 $ curl -fsSL | sudo apt-key add -

$ echo "deb [ arch=amd64 ] bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list

$ sudo apt update

$ sudo apt install mongodb-org

Please note:

To start mongodb and enable it as a system service:

 $ sudo systemctl start mongod
$ sudo systemctl enable mongod

You will see this port listening on the system:

 tcp        0      0*               LISTEN      12953/mongod        

Now, let's login into mongodb and issue a query command:

 $ mongo
MongoDB shell version v4.0.28

> show databases
admin 0.000GB
config 0.000GB
local 0.000GB

> use admin
switched to db admin

> show tables

All done.

Return to home | Generated on 09/29/22