Can not start MongoDB windows service on Windows 7 - mongodb

I have installed MongoDB 3.0.3 as a windows service on Windows 7 using below command
mongod --dbpath "E:\MongoDB\Data\db" --logpath "E:\MongoDB\Data\log\mongodb.log" --install --serviceName "MongoDB.3.0.3" --serviceDisplayName "MongoDB 3.0.3"
I can see the entry in services.msc. But when I start the service i get below error
I tried reinstalling it and even restarting the PC but nothing worked.

I got the solution.
The reason for this error was unclear shutdown of service(my PC got restarted abruptly dues to some windows update last day). this corrupts the database files.
So I deleted all the files from "E:\MongoDB\Data\db" folder and it worked.

Related

Mongo DB freezes during --config or --dbpath

(I am a Windows user)
I recently installed the MongoDB application onto a remote HDD. I have installed Mongo DB before on my Laptop's SDD and it worked perfectly. I am encountering an issue with the mongod --config "PATH to cfg file" command and the mongod --dbpath "PATH to database". When I run either command, the program halts (I can still close the Command Prompt window though). I am trying to change the database path because right now it defaults to C:/data/db even though Mongo is installed on a foreign Disk Drive. I have tried running both commands as a System Administrator to no avail. Any ideas as to I can solve this issue?

Can not run MongoDB using Ubuntu 14.04

I have installed mongoDB in my Ubuntu system but unable to start it.while i am running this service mongod start it throwing the following message.
start: Unknown job: mongod
Here i need to start the MongoDB. Please help me.
Looks like the mongod is not installed properly. Verify this by checking the presence of System V init script in location /etc/init.d/mongod. If not present, try installing the mongod again.

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.

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

Mongo 2.6.3 does not start on init

On fresh install of Ubuntu 14.04, I have installed mongodb 2.6.3 from mongo package,
problem is, that it does not start on reboot. It starts normally when I do
sudo service mongod start
and there are no errors in log file.
but when I reboot, log file has no new entries and
service mongod status
produces
mongod stop/waiting
I have tried mongod --repair, with no effect. I have tried fresh install of Ubuntu 14.04, as I thought that my older many times upgraded OS might have something wrong with it, but nothing changed.
With older version mongo that comes from ubuntu package manager, everything was starting up nicely.
Can you please give some advice on where to look to fix this issue and make mongod start up when system is booted up. Thanks!
Had the same problem. In the log file there was an:
************
Unclean shutdown detected
Please visit http://dochub.mongodb.org/core/repair for recovery instructions.
************
To solve this error, I just removed the lock file and it worked again.
sudo rm /var/lib/mongodb/mongod.lock
I believe the issue is that mongo upstart job checks if mongo is installed by the package manager. You need to edit the upstart job to use the new from-source binary location (which I think is /opt/mongodb/bin/mongod).