Reputation: 3919
I am trying to run a project with 2 MongoDB databases(db1, db2
) those are inside a file named dump
. I tried the following commands in 2 different terminals inside dump
folder:
mongod --dbpath=db1 --port=27017
mongod --dbpath=db2 --port=27018
Or the below command in one terminal outside of the dump
folder:
mongod --dbpath=dump
It seems both the ways work with no errors but when I check the project in localhost, it seems databases don't work properly!
How should i run a project with two databases on localhost using Windows10 command line?
There is also a file named config.js
in the project with the following code:
module.exports = {
'db1URL': 'mongodb://localhost:27017/db1',
'secretKey' : '1111-2222-3333-4444',
'db2URL': 'mongodb://localhost:27017/db2'
}
Upvotes: 0
Views: 48
Reputation: 28366
It sounds like you've gotten hold of a backup made with mongodump. That is not in a format ready to be used by the mongod process.
To restore the backup, you would first create an empty directory, then start mongod with dbpath pointing at that directory mongod --dbpath /datadirectory
, then run use mongorestore pointing to the dump directory like mongorestore dump/
.
Note that since you have attempted to start mongod pointed at dump, it has likely created some new files in these directories which may prevent mongorestore from completing. If that is the case, you will need to either remove these newly created files (hopefully you can identify them by creation date), or get a new copy of the dump.
Upvotes: 1