Reputation: 404
I started learning mongoDB a couple of days ago. Post installation, I am trying to change the dbpath as follows:
mongod --dbpath C:\myfolder\myproj\data\db
running the above command, I got the below statements in the command line:
Now i typed the below command to check if the dbpath has changed
mongod dbpath
this line still returns:
C:\data\db
I also tried running the below command to change the dbpath (as mentioned in a youtube video https://www.youtube.com/watch?v=pWbMrx5rVBE, but still the dbpath didn't change
mongod --directoryperdb --dbpath c:\myfolder\myproj\data\db
Can someone tell me how can I change my dbpath?
I looked at the stackoverflow question MongoDB not using /etc/mongodb.conf after I changed dbpath and also Unable to change the dbpath in mongodb through mongodb.conf but none of them helped
Upvotes: 0
Views: 3530
Reputation: 38529
When you run
mongod --dbpath C:\myfolder\myproj\data\db
You are starting an instance of mongod
with it's data directory as C:\myfolder\myproj\data\db
Running a second
mongod dbpath
is effectively starting a new instance of mongod
- which, by default, has its dbpath as \data\db
Just run mongod --dbpath C:\myfolder\myproj\data\db
as you are, then use mongo
to connect to it (or whatever client you're using)
When connecting to that instance, you'll be using the instance that is storing it's data in C:\myfolder\myproj\data\db
Upvotes: 3