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 https://www.mongodb.org/static/pgp/server-4.0.asc | sudo apt-key add -
$ echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu 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 127.0.0.1:27017 0.0.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
system.version
All done.
Return to home | Generated on 09/29/22