[mongodb] Failed to start mongod.service: Unit mongod.service not found

Just follow the below commands. This has worked for me.

  1. 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
    
  2. Now reinstall mongodb using following commands:

    sudo apt update
    sudo apt install -y mongodb**
    

    Note: The database server is automatically started after installation.

  3. 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**
    

Examples related to mongodb

Server Discovery And Monitoring engine is deprecated Avoid "current URL string parser is deprecated" warning by setting useNewUrlParser to true MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017] Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified Failed to start mongod.service: Unit mongod.service not found db.collection is not a function when using MongoClient v3.0 MongoError: connect ECONNREFUSED 127.0.0.1:27017 MongoDB: How To Delete All Records Of A Collection in MongoDB Shell? How to resolve Nodejs: Error: ENOENT: no such file or directory How to create a DB for MongoDB container on start up?

Examples related to ubuntu

grep's at sign caught as whitespace "E: Unable to locate package python-pip" on Ubuntu 18.04 How to Install pip for python 3.7 on Ubuntu 18? "Repository does not have a release file" error ping: google.com: Temporary failure in name resolution How to install JDK 11 under Ubuntu? How to upgrade Python version to 3.7? Issue in installing php7.2-mcrypt Install Qt on Ubuntu Failed to start mongod.service: Unit mongod.service not found

Examples related to ubuntu-16.04

Yarn: How to upgrade yarn version using terminal? pull access denied repository does not exist or may require docker login Failed to start mongod.service: Unit mongod.service not found How to completely uninstall python 2.7.13 on Ubuntu 16.04 Anaconda-Navigator - Ubuntu16.04 Default password of mysql in ubuntu server 16.04 Unable to set default python version to python3 in ubuntu "pip install json" fails on Ubuntu Unable to start the mysql server in ubuntu How to install php-curl in Ubuntu 16.04