Once you have the MongoDB packages installed, the next thing you should do is see whether you can start and connect the MongoDB server from your terminal. So, let's begin:
- Start MongoDB manually or automatically at boot time in the following commands:
$ sudo systemctl start mongod
$ sudo systemctl enable mongod
- Verify it by checking its version:
$ mongo --version
You should get a similar output to this on your terminal:
MongoDB shell version v4.2.1
git version: edf6d45851c0b9ee15548f0f847df141764a317e
OpenSSL version: OpenSSL 1.1.1d 10 Sep 2019
allocator: tcmalloc
modules: none
build environment:
distmod: ubuntu1804
distarch: x86_64
target_arch: x86_64
- Optionally, check the MongoDB server status with the following command:
$ sudo service mongod status
You should get the similar output to this on your terminal:
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled;
vendor preset...