Mongo data base - mongodb

Can't find my data base path in mongoDB.
I really need to know where my data is stored on my Mac OSX 10.7
And when I change my DBpath it keeps telling me that DBpath is not defined. (I am using homebrew)
Thank you in advance.

By default mongo configurations are stored on the following path.
/etc/mongod.conf
You can find the dbpath in the following file. By default it is :
/data/db or c:\data\db
You can change the dbpath using the following command
mongod --dbpath /data/newpath

You should be able to find the dbpath used by running the following command in the mongo JS shell:
db.serverCmdLineOpts()
Look for a parsed setting for "dbpath".

Related

Cannot start mongodb network service on Windows 10 after changing dbPath of config file

I have installed mongodb 4.2 on my Windows 10 PC. I want to change the dbPath from default C:\Program Files\MongoDB\Server\4.2\data to C:\Users\xx\Dropbox\mongodb_data.
I modifed mongod.cfg such that
dbPath: C:\Users\xx\Dropbox\mongodb_data
When I restart Mongodb network service, I encountered the following error;
How can I fix this error?
Try running MongoDB with additional parameter mongod --dbpath <your new path> it will be reading and writing to this new directory. So, if you want to still have the current documents in Mongo, you can move them to the new directory also.

Changing MongoDB 3.6 default db path in Windows

I just installed a new MongoDB 3.6 on my Windows machine. Now I'm trying to change the default DB path. So I tried this:
"C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe" --dbpath c:\mongodb\data
It worked, but only until I restarted Mongo. Then it was back to usual c:\data\db.
I tried to google it, saw some info about changing a mongod.conf file, but I can't find this file in my installation.
Any suggestions?
Save this script in a Batch File(Mongo.bat) and run it every time:
"C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe" --dbpath c:\mongodb\data
You need to start mongod with same command everytime:
C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe" --dbpath c:\mongodb\data
Or you can create a configuration file and install mongo as a service.
.

Create MongoDB database and set its path to a specific folder

I'm using ubuntu 16.04! Is it possible to change the data directory for a specific database in mongo? I'm trying to setup this recommendation engine and I was asked to create a new MongoDB database and set its path to folder.
Pre-version 3.0.0, all the databases that one mongod hosts have to be in the same dbpath folder which can be set via command arguments using the --dbpath flag or the config file.
You could however run multiple mongods and host them individually? either on different ip/ports.
Version 3.0.0 you can use the --directoryperdb flag within the command arguments or config to set multiple directories per database (See https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption--directoryperdb)
Uses a separate directory to store data for each database. The directories are under the --dbpath directory, and each subdirectory name corresponds to the database name.
When you start mongod.exe you can set the database path with the
mongod.exe --dbpath "path to your folder"
setting.
yes it's possible, run mongod process with --dbpath option

Unable to change dbpath in MongoDB using command line

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
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

How can I access copied mongodb folder

I just got copied database folder(literally copy and paste) of mongodb.
Actually, I'm beginner of mongodb and have a lot of problem to access copied database.
Could you give me any advice?
To start the database with the new directory - you can do the following:
Change dbpath in config: link, then restart mongod service
Run single mongod instance like "mongod --dbpath /data/db".
If you use WireTiger engine - "mongod --dbpath /data/db --storageEngine wiredTiger"