Unable to start mongodb - mongodb

I'm trying to install mongodb on my window 7 machine. When trying to start it by using the mongod command I get this error. dbpath (\data\db) does not exist. I followed the steps ath the tutorial. All the folders exist C:\mongodb\log, C:\mongodb\data and C:\mongodb\data\db .

The default path is c:\data\db. You are trying to use c:\mongodb\data\db.
This means you have to use the option --dbpath c:\mongodb\data\db for mongod command.

By default, when we start the mongodb, it looks for the folder /data/db (on Mac/Linux) or C:\data\db (on windows)...however, during the installation it doesn't create this folder, so when when we run mongodb for the first time, it fails with the error that it can't find C:\data\db folder. The solution is to manually create C:\data\db folder and then start mongodb. This error can be totally avoided if the mongodb installer can just give an option to choose this folder path and then create it as part of mongodb installation itself.

In windows you might not have permission for your user. And mongo installer could not create it because of lack of Administrative permission for your user.
So in C:\Program Files\MongoDB:
Create a folder named data
Create a folder named db inside the folder data
Now right click on the data folder and choose properties
Click security tab and select your user there
Click the Full control select box
Click ok, ok, ok ...
important! if you don't have the path "C:\Program Files\MongoDB\Server\3.4\bin" set in environment variable, please set it.
Now go to shell and type : mongod --dbpath "C:\Program Files\MongoDB\data\db"
That's it :)

Try to use 2 command Prompts (CMD) at the same time.
First CMD, use the command:
mongod (or mongod --dbpath C:\mongodb\data)
Second CMD, use the command:
mongo
The second will connect in the database. Do not close the first.

Related

What means this error in MongoDb running mongodb package for the first time?

$ mongo
BadValue: error: no args for --configdb
try 'C:\Program Files\MongoDB\Server\6.0\bin\mongos.exe --help' for more information
mongod says waiting for connections on port 27017. Whats the problem with mongo?
My path to mongo is: alias mongo="/c/Program\ Files/MongoDB/Server/6.0/bin/mongos.exe"
For everybody with the same problems of MongoDB installiation on Windows accordingly Udemy course of Full stack Bootcamp.
Download current version of Mongodb community server (msi) save it in Program files->Mongodb folder then you should download (https://downloads.mongodb.com/compass/mongodb-mongosh_1.5.1_amd64.deb) MongoDB shell because in 6.0 version or later there is no mongo.exe. save it to Mongodb folder. Save the variables mongod and mongosh via vim or interface tools (.dash_profile). I created via vim. Mongod variable is path to you mongod.exe and mongosh is the path to mongosh.exe. and run the mongod and mongosh in separate terminal tabs. For me it was necessary to rename mongorc.js to mongoshrc.js I used mv mongorc.js mongoshrc.js and that's all. Please be attention if you have old .bash_profile. You need to remove them (rm) because it grabs the first one. Check the list with ls -a.
download the shell from latest version here:
https://www.mongodb.com/try/download/shell?jmp=docs
mongo is change to mongosh, extract the folder in your desire directory, and change your "atlas mongos" path to "mongosh.exe" path. "mongosh.exe" path will be in bin folder of the downloaded zip file.

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

Mongo is unable to start

I'm trying to start mongo uin windows10 by type: mongo in cmd.
I am getting this error:
C:\Users\Itzik>mongo
MongoDB shell version v3.4.1
connecting to: mongodb://127.0.0.1:27017
2016-12-26T19:00:16.604+0200 W NETWORK [main] Failed to connect to 127.0.0.1:27017 after 5000ms milliseconds, giving up.
2016-12-26T19:00:16.605+0200 E QUERY [main] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:234:13
#(connect):1:6
exception: connect failed
C:\Users\Itzik>
I have opened port 27017 in the firewall,
and restart mongo's services
and it still dont work.
what could it be?
Have you started the server? Mongodb follows a server-client architecture. mongo is the client, but before it is started you need to start mongod, which is the server.
If you haven't, start the server in advance in a different console:
mongod --dbpath "c:\data"
replacing c:\data by any folder where you want to store your data (you need to create the folder in advance).
If mongod is not in the path look in the installation path, it should be something like C:\mongodb\bin\mongod.exe.
When the server says something like 'waiting for connections', then you can go to another console and type mongo to start the client.
In C:\Program Files\MongoDB\ you might not have permission to create file/folder for your user. And mongo installer cannot create it because of lack of Administrative permission for your user.
So in C:\Program Files\MongoDB:
Create a folder named data
Create a folder named db inside the folder data
Now right click on the data folder and choose properties
Click security tab and select your user there
Click the Full control select box
Click ok, ok, ok ...
important! if you don't have the path "C:\Program Files\MongoDB\Server\3.4\bin" set in environment variable, please set it.
Now go to shell and type : mongod --dbpath "C:\Program Files\MongoDB\data\db"
That's it :)
First start the server.
Goto your installation path. Mine was in "Program Files/Mongodb/server/bin"
You will find a "mongod.exe" application.
However, the server will look for "C:/data" folder for all the databases.
So create the "C:/data" folder.
Now start the mongod.exe using command prompt.
>>mongod
After this you may start the client
>>mongo
This worked out for me.
Open the terminal as Administrator.
(You can simply do this by searching cmd in start and then right click and select "Run as administrator")
Go to bin directory of your MongoDB folder.
cd C:\Program Files\MongoDB\Server\3.4\bin
Type following command to start mongodb server :
mongod --dbpath "C:\Program Files\MongoDB\Server\3.4\bin\Data"
now, server will be waiting for connections.
Open a new command prompt(again as Administrator)
Go to bin directory.
cd C:\Program Files\MongoDB\Server\3.4\bin
Type following command:
mongo
This will show you a prompt of mongodb :
>
Thanks.
if u install by brew (on osx)
first run sudo mkdir /data/db
start mondoDB Daemon by typing mongod (leave it open) and then
run mongo by typing mongo in new terminal tab
I also have faced the same problem.
First i have typed mongodb in my command prompt ,It displays "waiting for connection on 27017" that means it is working.
Then i type mongo in another Command prompt Window then above error occurred.
I was having both .dll files in my xampp\php\ext folder.
(php_mongo.dll and php_mongodb.dll)
I deleted Php_mongodb.dll and also it's extension from php.ini file.
Again restart command prompt,Type mongod and then mongo
Now working correctly.
First set the path in Enviroment Variables, C:\Program Files\MongoDB\Server\3.6\bin
after that use bellow command
C:\>mkdir data
C:\>cd data
C:\data>mkdir db
C:\data\db>
Then go to bin directory and select mongod.exe or use mongod. Without closing previous cmd
open a new cmd and start the client using mongo
Now it will work.
This issue is resolved by creating a data directory
Then move to the bin folder of mongodb or setting path information in environment variables
Then you can enter the following command,
mongod --dbpath 'path of the data folder including data directory name'
Eg: mongod --dbpath c:\users\codemaker\data

MongoDB 3.0 Windows Service Start : System Error 2 has occured

I have downloaded the MongoDB Windows msi install and run this successfully.
The mongod.exe and mongo.exe command file executions work properly.
The installation manual shows how to create the configuration file, and then to create the Windows Server using the command
sc.exe create MongoDB binPath= "\"C:\mongodb\mongod.exe\" --service --config=\"C:\mongodb\mongod.cfg\""
This creates a SUCCESS response.
The service is then started
net start MongoDB
but this produces the response
System Error 2 has occurred.
The system cannot find the file specified.
The resolution, for those who need this, is that the manual indicates the incorrect default path for mongod.exe, which should be in the bin directory
C:\mongodb\bin\mongod.exe
Thus, whereas this is a question, I have also solved this for the benefit of others who may have this problem.
Also, by default, MongoDB will install in C:\Program Files in Windows, and you should use the custom install to put it into C:\mongodb.
It can be possible that you already have a service named "MongoDB" before your installation and thus it is not successfully installed.
try to remove the previous one using this:
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --remove
and then you can try install the service again and fire the net start MongoDB command. It should work now.
I have faced this problem.And I solved as below.
1) Create this folders
C:\data\db
C:\data\log
2)Run CMD as administrator
C:\Windows\System32\cmd.exe
3)If you've installed service , write below to cmd to remove
C:\Program Files\MongoDB\Server\3.6\bin> mongod.exe --remove
4) This is important , I don't use sc.exe Determine the log and db directory ,and instal service
C:\Program Files\MongoDB\Server\3.6\bin> mongod.exe --logpath c:\data\log\mongod.log --dbpath c:\data\db --directoryperdb --install
5)If success
net start MongoDB
After having installed mongodb in C:\mongodb you just do:
mongod --install --logpath C:\mongodb\logs\mongo.log
The path to the logfile must exist and it must be an absolute Windows path. Then you start the MongoDB service by typing:
net start MongoDB

connecting to test mongoDB is failed

I am new in mongoDB
I have tried to install mongoDB on win 8 - 32 bit
I followed "The Definitive Guide To MongoDB 2010" by Apress.
I pasted the file in C drive root "mongodb-win32-i386-2.4.6"
Then I created nested folder in C
data/db ,
As the book was mentioned.
After that I opened cmd :
cd C:\ mongodb-win32-i386-2.4.6
cd bin\
up to here everything went well
then I tried to connect to mongo
but :
mongo
couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
exception: connect failed
occured.
Where is problem?
Thanks in advance
First Thing is
MongoDB is almost always run as a network server that clients can connect to and
perform operations on so
create a folder data and in that db folder i.e., c:\data\db
First we need to start the server with the command mongod.exe avial in your bin folder
like C:\mongodb-win32-i386-2.4.6\bin\mongod.exe
Run the mongo.exe avail in the bin folder like C:\mongodb-win32-i386-2.4.6\bin\mongo.exe
Know How to stop the mongod.exe
from the client we need to issue these commands
use admin
db.shutdownServer()
then automatically mongod will shut and you need to quit from client with exit command
HAVE A NICE DAY WITH MONGO
The database itself is an executable called mongod.exe (mongoDB daemon). First you need to start this one. When it is running, you can use mongo.exe (mongoDB shell) to connect to it and issue commands.
For more information, read the article "Install MongoDB on Windows" from the official manual.
i have tried the binary files from https://www.mongodb.org/dl/win32/i386
After installing above binary file please go to bin directory (C:\Program Files\MongoDB\Server\3.2\bin -> default installation directory) and run following command
mongod.exe --journal --storageEngine=mmapv1 --dbpath c:\data\db
Note:make sure that you have already created the c:\data\db directory
Also if you need a GUI interface for mongodb, you can use Mongobooster