title: how to completely remove mongoDB with all instance from ubuntu
body: <p>How to completely uninstall mongoDB with all its instances, and re-install it.</p>
  
  <p>I've tried this,</p>
  
  <pre><code>sudo service mongod stop
  
  sudo apt-get purge mongodb-org*
  
  sudo rm -r /var/log/mongodb
  
  sudo apt-get autoclean
  
  sudo apt-get autoremove
  
  sudo apt-get purge mongodb-org*
  </code></pre>
  
  <p>But its giving the below error :</p>
  
  <blockquote>
    <p>sudo rm -r /var/log/mongodb its giving error :rm: cannot remove
    '/var/log/mongodb': No such file or directory</p>
    
    <p>sudo rm -r /var/lib/mongodb its giving error :rm: cannot remove
    '/var/lib/mongodb': No such file or directory</p>
  </blockquote>
  
  <p>Now still, it's not removed completely.</p>
  
  <blockquote>
    <p>reema@reema-s ~> mongo MongoDB shell version v4.0.11 connecting to:
    mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
    2019-07-25T15:45:34.860+0530 E QUERY    [js] Error: couldn't connect
    to server 127.0.0.1:27017, connection attempt failed: SocketException:
    Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused
    : connect@src/mongo/shell/mongo.js:344:17 @(connect):2:6 exception:
    connect failed reema@reema-s ~></p>
  </blockquote>