Just follow the below commands. This has worked for me.
Uninstall your mongo completely from your system:
sudo service mongod stop
sudo apt-get purge mongodb-org
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
Now reinstall mongodb using following commands:
sudo apt update
sudo apt install -y mongodb**
Note: The database server is automatically started after installation.
Next, let's verify that the server is running and works correctly.
sudo systemctl status mongodb
You'll see this output:
mongodb.service - An object/document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2018-05-26 07:48:04 UTC; 2min 17s ago
Docs: man:mongod(1)
Main PID: 2312 (mongod)
Tasks: 23 (limit: 1153)
CGroup: /system.slice/mongodb.service
+-2312 /usr/bin/mongod --unixSocketPrefix=/run/mongodb --config /etc/mongodb.conf**