Mongod not working but data exists

I am running a Homestead virtual box. I installed mongodb recently and was able to type mongod and it would load as it should. Now though I get an error saying dbpath /data/db does not exist. The typical solution for that is to create /data/db and set the proper permissions. The problem is that I already have data, just not in that location. My site is able to connect to mongodb and access information…

I noticed my .0 and .ns file, which I assume are my data files, are actually saved in /var/lib/mongodb as well as a mongod.lock file

I tried setting my dbpath using “mongod –dbpath /var/lib/mongodb” to which I get an error:

exception in initAndListen: 10308 Unable to create/open lock file: /var/lib/mongodb/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating

I’ve tried stopping mongod and then running the –dbpath command which produced the same error. I’ve also tried running in sudo

Answer

I decided to keep this up in case someone else runs into the same problem. The problem was that I was using:

mongod

when I should have been using:

mongo

Attribution
Source : Link , Question Author : Tyler , Answer Author : Tyler

Leave a Comment