Can't start mongodb server in windows 7 - mongodb

I am using windows 7 64 bit laptop ,it contain 8 gb RAM ,i installed mongodb sucessfully ,while i am trying to connect the server using the "net start MongoDB" i stuck there lot? and it show service name is invalid, anyone could help me to retify this problem?

Open command prompt,
Navigate to where the mongodb is installed(usually at C:\Program Files\MongoDB\Server\3.2\bin),
Type mongod and hit enter.

From MongoDB documentation :
Start MongoDB.
To start MongoDB, run mongod.exe. For example, from the
Command Prompt:
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe"
This starts the main MongoDB database process. The waiting for
connections message in the console output indicates that the
mongod.exe process is running successfully.

You take a look into log of console , you will see path of db (ex:C:\data\db)
Mongod not auto create folder when it not exist
You should create folder struct follow the log then run mongod.exe again. It will work.

Related

How to get mongod.exe to start via gitbash?

I was having problems with getting mongo (via mongosh command) to start in gitbash.
I was able to solve it via getting mongod.exe to start in windows(10) via ControlPanel>System/security>AdministrativeTools>Services (following the answer at https://stackoverflow.com/a/56354829/5358730).
Further to that I was wondering whether there is a way to do the same via commands written in the gitbash terminal itself?
I notice there several questions on asking mongodb to start (eg How to start mongdb How to start MongoDB server? How to start using MongoDB? How to start mongodb in windows 10 How to start mongodb shell? Start mongo from Windows command file), but I dont think these address using gitbash commands to get the file to start. Apologies if I've missed anything.
Thanks.

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

Windows could not start mongodb service on local computer. For more info., review the System Event Log

I am using Windows 32-bit machine and tried to start MongoDB service from Windows > services as shown below.
However, I am unable to start the MongoDB service from it and throws the following error.
When I try using cmd prompt, I am getting the following error:
Network Failed to connect to 127.0.0.1:27017, reason: errno:10061 No
connection could be made because the target machine actively refused
it.
Error: Couldn't connect to server 127.0.0.1:27017 <127.0.0.1>,
connection attempt failed.
I had same an issue.
Try to remove mongod.lock file from your Mongo data directory.
For example mine is "C:\Program Files\MongoDB\Data\mongod.lock" and after deleting file start the MongoDB service and it's work like charm.
In case someone else is running into this problem, just read your Log files and you will be able to find the problem, for me after trying to install it inside wamp directory when I run the MongoDB service it gave me the same error message, I went to the logs and find out that I was missing a directory inside my data directory which is called db, once I have created this directory the service run perfectly.
MongoDB uses a default folder to store its files. On Windows, the default location is C:\data\db.
Maybe that folder doesn´t exist. In that case just creat it or change the default location of Mongo service using the --dbpath command-line flag.
So I just had the same problem, running on Windows 10. The reason why MongoDB didn't start was because the path to the data and logs was not correctly set. This has already been pointed out, but my solution is different. Look in C:\Program Files\MongoDB\Server\4.0\bin (or wherever your mongoDB is installed). There is a config file called mongod.cfg. Check that
storage:
dbPath:
and
systemLog:
path:
Is set to what you want. In my case, it was using environment variables %MONGODBPATH% or similar that was not set by Windows. By default, the log and data should point to C:\Program Files\MongoDB\Server\4.0\data and C:\Program Files\MongoDB\Server\4.0\log\mongod.log respectively.
There was a npm: in last line of mongodb configuration file which is located in the installation folder in the bin\mongod.cfg
I commented out that line and started the service and it is working like charm.
I concluded this by running the mongodb service command from windows command line(cmd) and I got an error.
I ran this to spot the error:
C:\Program Files\MongoDB\Server\4.2\bin\mongod.exe --config "C:\Program Files\MongoDB\Server\4.2\bin\mongod.cfg" --service
mongod.lock deletion did not helped me, repair did not help either. In my case it was due to one of database happened to be corrupted, I moved all dbs to another directory and then copied them back one by one and re-starting mongodb service to figure out what db file is corrupted. It's definitely MongoDb bug
I had the same error message. Try to locate the mongodb log files and look at the last entries. My issue was clearly stated there, a missing directory :
2019-01-29T16:59:44.424+0100 I STORAGE [initandlisten] exception in
initAndListen: NonExistentPath: Data directory
C:\wamp64\bin\mongodb\mongodb-win32-x86_64-2008plus-ssl-3.6.10\data\db
not found., terminating
The advice of checking the log was what helped me. In this case:
The MongoDB service could not be started. A service specific error occurred: 100
turns out I had a problem with some databases created with WiredTiger while the mongod.cfg specified engine was: mmapv1
So I basically removed the content of the folder c:/data/db/ and then used the command net start MondoBD --repair and worked. Uffff it´s been 2 days.
I'm here a bit late, very late actually. But may it works something out for the ones facing this issue now. Mongodb configuration file in Windows OS is under 'C:\Program Files\MongoDB\Server\%YOUR MONGO VERSION%'.
I had changed this file and manipulated the bindip field, so I was getting the same error. It should be 127.0.0.1 or your machine's IP address which you can find it by 'ipconfig/all' command in cmd. So I fixed bindip and the service starts with no problems.
stuck on the same issue, but got the solution by hit and trial, just create a new folder for path "C:\data\db" then go to your command prompt and type 'mongod', your database server will start.
For me it was a port problem :
just search and kill the process using the port 27017
for linux : https://bobcares.com/blog/mongodb-error-code-48/
for windows : How do I kill the process currently using a port on localhost in Windows?
I have found out that Visual C++ Redistributable was missing in my Windows 7 Machine. After installing it worked.
For Windows 10 users
specify database location, if don't know create the below-mentioned directory and always use this
open cmd
mkdir C:\users\{username}\data
cd C:\users\{username}\data
mongod --dbpath .
start mongodb server
open cmd
mongod --dbpath C:\users\{username}\data
stop mongodb
open cmd
mongo
if server is running, run:
use admin
db.shutdownServer()
quit()
In my case, this happened because I did not stop MongoDB from docker. after I stopped the process the error was gone.
In my case, it was the docker with MongoDB running on the same port. So after I stopped the container, the service is then successfully starting.

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

install mongodb on window 8

I try to install mongodb on window 8 .
problem is when i want to install mongodb service
C:\mongodb\bin\mongod.exe --auth --config C:\mongodb\mongod.cfg --install
below error accord
Wed Mar 13 19:13:23 Trying to install Windows service 'MongoDB'
Wed Mar 13 19:13:23 Error connecting to the Service Control Manager: Access is denied. (5)
how Can I Install Mongodb Service?
Open Command with "Run as Administrator",that solved my problem
For anyone that happens to try to create a mongodb service on Windows 8 and follows the instructions on MongoDB's website AND still is unable to create the service successfully - I've written this post that explains how I got it to work after experiencing problems trying to set the mongo service on my Windows 8 laptop. Hope it helps!
Here are the steps that you really need to follow to create a Windows service for MongoDB in Windows 8:
Installing MongoDB on Windows 8
Download and install MongoDB. You can download the 32 or 64-bit version from here.
Make sure you install MongoDB in a folder that you can easily remember, for example: c:\mongodb\
Add directories c:\mongodb\log and c:\mongodb\data
Add log file c:\mongodb\log\mongo.log
Creating a Windows service for MongoDB
Open your command window and type the following:
cd c:\mongodb\bin\mongod.exe --install --rest -master -logpath=c:\mongodb\log\mongo.log
Open the registry settings, press the Windows key and R at the same time and then type regedit in the Run command window.
Go to HKEY_LOCAL_MACHINE >> SYSTEM >> CurrentControlSet >> services
Find out MongoDB directory & edit ImagePath key
Set key value as:
C:\mongodb\bin\mongod --service --rest --master --logpath=C:\mongodb\logs\mongo.log --dbpath=C:\mongodb\data
Save and exit registry editor.
Open Services by pressing the Windows key and R at the same time and then type services.msc in the Run command window and click OK.
Find the MongoDB service and right-click on it, select Properties
Make sure the service is set to start automatically and start the service as shown below.
Open your browser and go to http://localhost:28017/ to see if MongoDB is running correctly, you should see a page full of MongoDB details.
Link to this blog post:
http://ricardodsanchez.com/2014/09/03/install-mongodb-service-on-windows-8/
error message suggest you don't have admin privileges.
"Run all of the following commands in Command Prompt with “Administrative Privileges:”"
Ref: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/#install-and-run-the-mongodb-service
Regards,
Moacy
thanks for answer Moacy Barros but problem was not for this because i run all commands in Command Prompt with “Administrative Privileges:”" problem was for mongod.cfg if mongod.cfg config by manual in editor this problem solve that we didn't need to do this in window 7 or server 2008
Edit::
in older windows when installing MongoDB < 2.2 that i was tested. in Configure directories and files step
echo logpath="C:\Program Files\MongoDB\log\mongo.log" > "C:\Program Files\MongoDB\mongod.cfg"
it make mongod.cfg for your mongodb but it wasn't make for me in window 8 for that i make it by manual like
logpath=C:\mongodb\log\mongo.log
logappend=true
dbpath = E:\data