MongoDB not working. "ERROR: dbpath (/data/db) does not exist." MongoDB not working. "ERROR: dbpath (/data/db) does not exist." express express

MongoDB not working. "ERROR: dbpath (/data/db) does not exist."


This should work to ensure that the directory is set up in the right place so that Mongo can find it:

sudo mkdir -p /data/db/

sudo chown `id -u` /data/db


You need to create the directory on root /data/db or set any other path with the following command :

mongod --dbpath /srv/mongodb/

See the example link


I solved the problem with :

sudo mongod --dbpath=/var/lib/mongodb and then mongo to access the mongodb Shell.