I am new to mongo, and I am trying to install mongo on my windows system. I am following THIS tutorial, but when I do
C:\mongodb\bin\mongod.exe
my CMD gives me this output
2015-04-20T18:53:27.433+0500 I STORAGE [initandlisten] exception in ini
en: 29 Data directory C:\data\db\ not found., terminating
2015-04-20T18:53:27.436+0500 I CONTROL [initandlisten] dbexit: rc: 100
MongoDB requires a data directory to store all data. MongoDB’s default data directory path is \data\db.
Create this folder
md \data\db
You can specify an alternate path for data files using the --dbpath option to mongod.exe, for example:
C:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\data
If your path includes spaces, enclose the entire path in double quotes,
for example:
C:\mongodb\bin\mongod.exe --dbpath "d:\test\mongo db data"
Read more in detail
I fixed the same using :
Create a folder data in
D:\project-workspace\mongodb\data
Then Create another folder db inside data
ie,
D:\project-workspace\mongodb\data\db
Then run the command
mongod --dbpath D:\project-workspace\mongodb\data\db
Make sure you have set environment variable for mongodb else browse C:\Program Files\MongoDB\Server\3.4\bin and then execute this =>
mongod.exe --dbpath E:\workspace\mongodb\data
I also faced the similar problem on windows, moreover, i dont have my environment variable set so i have to go to bin folder and run mongo. Below are the steps i followed
1) I created a folder on my desktop something like "C:\Desktop\data\"
2) In order to use mongo shell, you need to run mongo which is similar to a daemon on unix, so in windows, we can do it by opening a command prompt window and change directory to mongo\bin and run
mongod --dbpath C:\Desktop\data and left it runnning
3) I opened second command prompt window, did a change directory to C:\mongo\bin
and executed mongod, that's it
Because MongoDB does not know the directory DB.
Fixed Work for me.
Step 1: New Folder e.g. Run cmd
mkdir E:\workspace\mongodb\data
Step 2: Move to Root MongoDB path e.g. (cd .../MongoDB/.../bin/)
C:\Program Files\MongoDB\Server\3.4\bin>mongod.exe --dbpath E:\workspace\mongodb\data
Ok.
Also faced the same issue in windows. if --dbpath directory path does not contain spaces, do not include quotes. Removing quotes, when the path does not have space, resolved the issue.
Related
When running a shell command in docker exec with a local file as an argument, it fails with
-bash: docker/mongo.archive: No such file or directory
$ docker exec -i 4cb4a63af40c sh -c 'mongorestore --archive' < 'docker/mongo.archive'
-bash: docker/mongo.archive: No such file or directory
However, the file clearly exists at the given location:
$ ls docker/mongo.archive
docker/mongo.archive
I remember using the exact same command and it worked. Also, I tried calling the command from within its directory (./docker) as well as from outside, using relative paths. Using the absolute path fails as well. Any ideas?
Remark: 4cb4a63af40c is a mongodb container.
Adjust the quotes
docker exec -i 4cb4a63af40c sh -c 'mongorestore --archive < docker/mongo.archive'
I'm trying to install and run some basic commands on mongodb from this tutorial (on page 4).
So far,
I've downloaded the a 32-bit zip file from the mongodb download page.
I've unzip the file in the following locations home/user1 then renamed it to mongodb
I've create a folder called data then another one inside called db
I've created a file name mongodb.config containing the path of the folder where I want to store my data, which is mongodb/data/db.
But when I run the command to start the server:
user1#user1-VirtualBox: ~$ mongodb/bin/mongod --dbpath ~mongodb/data/db
I'm getting the following error:
bash: mongodb/bin/mongod : No such file or directory
Am I missing something?
Missing a '/', it should be ~/mongodb/data/db, not '~mongodb/data/db'
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I have mongo DB installed in the following path c:\mongodb\bin. I have configured my environment variable PATH in advanced settings.I also have mongod running .When I run the following command mongorestore dump from the following path c:\hw1-1\dump (This contains the BSON files) I'm getting this error:
Don't know what to do with the dump file
I have referred to this thread to check my path.
in mongodb 3.0 or above, we should specify the database name to restore
mongorestore -d [your_db_name] [your_dump_dir]
You probably saw this error:
ERROR: don't know what to do with file [dump]
Which means in this case, that there is no file or directory called dump in your current working directory. So, Try this first cd c:/hw1-1/ (or whatever the correct syntax is on Windows, I can't test it.) Alternatively you can specify the full path to the dump directory:
mongorestore c:/hw1-1/dump
If you're using mongoexport to create the dump, be sure to use mongoimport rather than mongorestore to load it.
This error message "don't know what to do with file" can also occur if you have a BSON file that does not have a .bson file extension.
Generally this isn't a problem since mongodump generates the files with .bson extensions, but in my case I had a BSON file that was not generated by mongodump and had a different file extension.
I'm on version 3.2 windows and my mongorestore seems to have a bug:
If I specify /db:database_name or /d database_name I get the error:
don't know what to do with subdirectory "dump\database_name", skipping...
Instead if I let it run on the whole dump directory it seems to work. The command I used is:
mongorestore /host:remote_host dump
My current directory structure is:
.
..
dump
dump\database_name
I got this error when I had a collection matching the name of the one I was trying to restore present in Mongo ended up going into Mongo and deleting it using db.m101.drop();
It took me some time to figure out the options for mongorestore , after i had kept getting this error for some time .
a) No running instances of mongod .
b) mongorestore -v -host localhost:27017 --dbpath "Actual Path for the Mongo DB- set in config" "Location where the dump is"
Using dbpath , allows to run this command without any running version of mongod .
And this resolved my error .
When initially setting up mongodb I must've done something wrong as my data isn't being written to /data/db as I intended. I have no idea where my data is being stored (doing a search in finder for the db naem returns no results and I can't find in the docs how I can find out the current directory used). How can I safely point mongodb to use my desired directory while making sure it moves all my existing data to the new location?
The way to change the dbpath is to stop your mongod instance, copy the contents of the dbpath directory to their new location, and then restart it with the new dbpath parameter set properly.
First, in order to determine the current setting of the dbpath, you can use the getCmdLineOpts command. Here's how to use it from the mongo shell:
> db.serverCmdLineOpts()
{
"argv" : [
"mongod",
"--config=/Users/dstorch/foo.conf"
],
"parsed" : {
"config" : "/Users/dstorch/foo.conf",
"dbpath" : "/data/db"
},
"ok" : 1
}
As you can see, "parsed.dbpath" will give the current value of the dbpath.
Say you wanted to change the dbpath from /data/db to /data/db2. First you need to shutdown mongod. You do this by sending SIGTERM, either with Control-C or with kill <pid>. A third option is to run the shutdown command.
When mongod has safely exited, copy your data to its new location, and restart with the new dbpath:
cp -r /data/db /data/db2
mongod --dbpath /data/db2
Is there a command to clear the history from within the mongo shell?
There should be a file called .dbshell in your home folder. Just delete it.
MongoDB terminal history is stored inside the ~/.dbshellfile. Just empty the .dbshell file
$ > ~/.dbshell
Versions of Windows mongo.exe earlier than 2.2.0 will save the .dbshell file in the mongo.exe working directory.
You can clear contents on the shell by Ctrl + L
Command history is stored in ~/.dbshell file.
For example, on a Unix-like system:
# Ensure an empty history file
echo "" > ~/.dbshell
# Remove rwx access to the history file
chmod 0 ~/.dbshell
If you're using MongoDB Shell as a standalone package, you will find the shell history file located in ~/.dbshell
If you're using the embedded MongoDB Shell inside MongoDB Compass, you will find the shell history file located in ~/.config/MongoDB Compass/MongoDB Compass/shell-history.json
Just empty the history file