Running mongod as a windows service - windows

i have installed mongodb on win32 and i am trying to run it as a service.
I have followed the instructions posted here: http://www.deltasdevelopers.com/post/Running-MongoDB-as-a-Windows-Service.aspx
but when when windows tries to 'load'/'run' the service there is a problem. I see the service under the services control banner constantly in the 'starting' state.
The result: the service is not started and windows is constantly trying to start it without success.
The instructions i have followed are:
At the command line
C:\mongodb\mongod -install
then
C:\mongodb\mongod -service
Then i modified the Win Registry Entry for the MongoDB Service by setting the ImagePath key to the value of C:\mongodb\mongodb.exe -service
Any advice? What am i doing wrong?

Just for future reference: running mongo as a windows service
Also lots of people seem to be saying: specify the whole path to the mongod.exe:
c:\mongo\mongod.exe --logpath "c:\mongo\logs\mongo.log" --logappend --dbpath "c:\mongo\data" --directoryperdb --install
Also if you're running Windows 7 don't forget to run the command window as an administrator.

I'd do it this way just cause I like to customize/organize things better:
Unzip mongo to where you want.
I like putting all the configuration in a file (my preference, since I didnt like default location of C:/data/db, and didn't like all the options as commandline params)...
Looks something like:
[C:\dev\mongodb\data\mongodb.conf]
dbpath = C:\dev\mongodb\data\db
logpath = C:\dev\mongodb\data\mongodb.log.txt
logappend = false
Then I put C:\dev\mongodb\bin in my Env Variable's PATH (so can call mongo.exe from any dir), but not needed...
Then on command line to install the Windows Service:
$ cd C:\dev\mongodb\bin
$ mongod.exe -f C:\dev\mongodb\data\mongodb.conf --install
It will create a Windows Service which if you want, can start manually via:
$ net start MongoDB
//Use qoutes if changed service name (via -serviceName to mongod --install), like: net start "Mongo DB"

Specifying several parameters at once is a good choice.
mongod
--install
to install as a service
--rest
to enable rest access to mongodb
–master
to set up mongodb instance as master.
–logpath
this is mandatory when you install mongodb as service
--dbpath
this too is mandatory for mongodb to run.
Here is a step by step guide describing the installation of MongoDB Service on Windows 7.

I have been faced similar issue. And i tried above solutions still have not get any result.
finally below code is solved my issue.
-> Command prompt open as administrator.
-> Copy and paste the below code after changing the proper bin and config path.
sc.exe create MongoDB binPath= "\"d:\MongoDB\bin\mongod.exe\" --service --config=\"d:\MongoDB\mongo.cfg\"" DisplayName= "MongoDB" start= "auto"
Happy Coding !!!!!!

Regardless of whether you're running as a service or not, you need to specify the --dbpath argument to mongod.exe.
Also, you shouldn't have to edit the registry. You can just issue the command like this:
C:\mongodb\mongod.exe --dbpath C:\data\db --install

Related

Installing Windows service with parameters

I have a series of basically identical custom services, which needs to be started with different parameters. The parameters specify which ports to use to communicate with an application, and they all need different ports. I install the services with a batch script:
cd %~dp0\InterfaceService_0x1C01
installutil interface.exe
cd %~dp0\InterfaceService_0x1C02
installutil interface.exe
Then start them like so:
cd %~dp0\InterfaceService_0x1C01
net start Interface0x1C01 /-ip=127.0.0.1 /-pn=32790 /-sp=32791
cd %~dp0\InterfaceService_0x1C02
net start Interface0x1C02 /-ip=127.0.0.1 /-pn=32792 /-sp=32793
It works fine, they all start up on different ports. But when I restart the computer, they start automatically without parameters. I've tried to modify the install script:
cd %~dp0\InterfaceService_0x1C01
installutil Interface.exe
sc config Interface0x1C01 binPath="C:\Program Files (x86)\InterfaceServices\InterfaceService_0x1C01\Interface.exe /-ip=127.0.0.1 /-pn=32790 /-sp=32791"
cd %~dp0\InterfaceService_0x1C02
installutil Interface.exe
sc config Interface0x1C01 binPath="C:\Program Files (x86)\InterfaceServices\InterfaceService_0x1C02\Interface.exe /-ip=127.0.0.1 /-pn=32792 /-sp=32793"
I've also tried without the slashes, but in both cases the service starts up on the default port.
Can someone help with this? I'd like this approach to work, but I could also accept help with installing them set to not start automatically and having a script start them automatically on startup - provided that the user would not need admin privileges at that point.

Mongodb: Failed to connect to 127.0.0.1:27017, reason: errno:10061

Here is my mongod.cfg file:
bind_ip = 127.0.0.1
dbpath = C:\mongodb\data\db
logpath = C:\mongodb\log\mongo-server.log
verbose=v
Here is my mongod service command:
mongod -f c:\mongodb\mongod.cfg --install
I have installed MongoDB about a week ago and it all worked fine, however today when I ran mongo command I got the following error:
Failed to connect to 127.0.0.1:27017,
reason: errno:10061 No connection could be made because the target machine actively refused it
How can I fix that? I use Windows 8.1
Solution:
I forgot to start mongodb service with this command:
net start mongodb
Improved solution:
1) Change directory to root drive C:\, and type the command below into an admin cmd prompt window,
C:\mongodb\bin\mongod.exe --config c:\mongodb\mongod.cfg --install
2) Then type net start MongoDB after which you should see the following message:
"The Mongo DB service was started successfully"
3) Then go to the control panel Start>Administrative Tools>Services, scroll down to MongoDB in the list of services and change start up type to automatic, if you so desire. Press OK.
4) Finally type C:\mongodb\bin\mongo.exe and you should be connected to the Mongo test DB.
Reference: https://www.youtube.com/watch?v=-mik4dPArCU
This is how I solved it, You can follow step by step here:
MongoDB Steps:
Download the latest 64-bit MSI version of MongoDB for Windows.
Run the installer (.msi file)
Add it to your PATH of environment variables. it Should be from:
C:\Program Files\MongoDB\Server\3.0\bin
now Create a “\data\db” folder in C:/ which is used by mongodb to store all data. You should have this folder:
C:\data\db
Note: This is the default directory location expected by mongoDB,
don’t create anywhere else
.
Finally, open command prompt and type:
>> mongod
You should see it asking for permissions (allow it) and then listen to a port.
After that is done, open another command prompt, leaving the previous one running the server.
Type in the new command prompt
>> mongo
You should see it display the version and connect to a test database.
This proves successful install!=)
Reference link
When you typed in the mongod command, did you also give it a path? This is usually the issue. You don't have to bother with the conf file. simply type
mongod --dbpath="put your path to where you want it to save the working area for your database here!! without these silly quotations marks I may also add!"
example: mongod --dbpath=C:/Users/kyles2/Desktop/DEV/mongodb/data
That is my path and don't forget if on windows to flip the slashes forward if you copied it from the or it won't work!
I was also faced the same issue with mongodb 2.6.
What solved my problem was I just run mongod --repair command
and then start mongod.exe
It's worked for me
just create a folder
C:\data\db
Run below commands in command prompt
C:\Program Files\MongoDB\Server\3.4\bin>mongod
Open another command prompt
C:\Program Files\MongoDB\Server\3.4\bin>mongo
mongodb 2.6.8 on windows7 32bits
you only need create a folder c:/data/db
execute mongod, and execute mongo
Point to your mongodb instalation e.g C:\Program Files\MongoDB\Serve\bin and run mongod.exe so you can open connection to 127.0.0.1:27017.
If it writes that you had not properly shut down or that mongod.lock is not empty
, only delete mongod.lock from C:\data\db\ and it will start.
The problem is that I missed out 'db' folder for the dbpath in the command:
C:\mongodb\bin> mongod --directoryperdb --dbpath C:\mongodb\data\db --logpath C:\mongodb\log\mongodb.log --logappend -rest --install
Under normal conditions, at least 3379 MB of disk space is needed. If you do not have that much space, to lower this requirement;
mongod.exe --smallfiles
This is not the only requirement. But this may be your problem.
What solved my issue was creating a file startmongo.conf that sets the bind_ip to 127.0.0.1 . After that, I just created a *.bat to start the mongo using something like:
mongod --config c:\mongodb\bin\startmongo.conf
When This Error is Coming it is lack of the following
1)Setting the path to mongo db
go to "C" Drive and the installation of Mongo db directory and then go to bin folder in the mongo and copy the path of it
c:/mongodb/server/3.2/bin/ and create a new environmental variable in system properties then name is path and value="c:/mongodb/server/3.2/bin/" here my version is 3.2
2)create a data directory for the data in C Drive
c:/Data/twitter
3)start the server with **
c:/> mongod
check your port config if there is any error as the local port may be assigned to any other
4)start your Mongo database with
Mongo
then your mongo db will start
then in your mongo database
create a database
use DATABASE_NAME
for example:
use twitterdata
switched to db twitterdata
to check your current database
db
twitterdata
to get total databases
show dbs
I started mongod in cmd,It threw error like C:\data\db\ not found.
Created folder then typed mongod
opened another cmd typed mongo it worked.
Here are the steps to solve this issue:
Just go to your MongoDB bin folder and run the mongod.exe file.
Navigate to your mongodb bin folder via Command prompt and start mongo by typing "mongo"
Change file permission to 755 for the file:
/var/lib/mongodb/mongod.lock
first you run the command mongod and check weather the port 27017 has started or not if yes then hit the command mongo....and database will start.
The Port is not open. Thats why the machine refuses communication
Try this, it worked for me.
mongod --storageEngine=mmpav1

Unable to start cygwin sshd service

I entered ssh-host-config into the cygwin prompt (started with admin privileges), said yes to privilege separation, new local account sshd, install sshd as a service; I entered no value for CYGWIN for daemon; I entered no for using a different name; yes for creating new privilege user account.
In my services.msc I am unable to start the service:
The CYGWIN sshd service on Local Computer started and then stopped.
Some services stop automatically if they are not in use by other services
or programs.
In the cygwin prompt, net start sshd produces:
The CYGWIN sshd service could not be started.
The service did not report an error.
More help is available by typing NET HELPMSG 3534
In the cygwin prompt, cygrunsrv -S sshd produces:
cygrunsrv: Error starting a service: QueryServiceStatus: Win32 error 1062:
The service has not been started.
My /var/log/sshd.log says the following:
Unable to initialize device PRN
I've searched the questions on SO related to this issue, as well as the general Internet, and I guess what makes my question unique has to do with the sshd.log. I can't find anyone else who has received this.
I'm doing this to install Hadoop on my Windows. I cannot run a virtual machine on this slow computer as everything just bogs down.
I followed the steps in this topic and the problem was still happening, then I checked the sshd log file and it was complaining that the privilegies of the ssh private key were to open.
I executed the follow command:
chmod 400 /etc/ssh_host_ecdsa_key
Then I run the service:
net start sshd
It finally worked (BTW: I am using Windows 8)
I had the same problem and here is the solution that worked for me.
Solution 1
Restart the machine after you set the path environment variables to point to Cygwin bin directories and then start the service.
Solution 2
First add the account that runs the Cygwin sshd demon service to administrators group (this is by default)
Go to your cygwin installation folder (mine is at c:\cygwin64 and yours may differ)
add administrators group as full control. remove the property
Remove Readonly for your cygwin installation folder so anyone can write into it
Run the cygwin terminal as administrator and remove the service by typing
cygrunsrv -R sshd
Reboot your system
Run the cygwin terminal as administrator and reinstall the service again by typing
ssh-host-config -y
Run the cygwin terminal as administrator and start the service by typing
net start sshd
Your service now be running!
I tried above solutions but nothing worked for me.
I am using Windows 8 and was able to solve it.
My sshd.log file says : "Privilege separation user sshd does not exist FAILED"
So to remove this error while starting sshd as service just following below steps:
Edit the file /etc/passwd --
add " sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin ".
Edit the file /etc/group --
add " sshd:x:74: ".
Now start service as
net start sshd
It worked for me!
Followed the steps provide by Andrea Solution 1 and solution 2 , it did not work. Event viewer did not provide any info.
So took a look at the log var/log/sshd.log first it complained that it was unable to load the dll:
/usr/sbin/sshd.exe: error while loading shared libraries: cygcrypto-1.0.0.dll
Solution:
Reinstalled the package and ensured that the dll were in lib.
Started the service again still it failed but this time it complained about missing host key.
Could not load host key: /etc/ssh_host_dsa_key
Could not load host key: /etc/ssh_host_ecdsa_key
Disabling protocol version 2. Could not load host key
sshd: no hostkeys available -- exiting.
Solution:
go to the Cygwin Command prompt (with run as admin ) and
enter ssh-keygen -A
the missing host key were generated .
Finally I was able to start it.
I would recommend looking at the log file further if the above solution does not work.
In my case (using a Polish version of Windows 8) I had to manually modify the /etc/passwd and /etc/group files.
Some lines for Administrator, Administrators, Guest, Guests, etc. had been missing, so I merely inserted them, and copied all other fields from their non-English versions. Eg.
nano /etc/passwd
SYSTEM:*:18:544:,S-1-5-18::
LocalService:*:19:544:U-NT AUTHORITY\LocalService,S-1-5-19::
NetworkService:*:20:544:U-NT AUTHORITY\NetworkService,S-1-5-20::
Administrators:*:544:544:,S-1-5-32-544::
Administratorzy:*:544:544:,S-1-5-32-544::
TrustedInstaller:*:4294967294:4294967294:U-NT SERVICE\TrustedInstaller,S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464::
Administrator:unused:500:513:U-gordito\Administrator,S-1-5-21-580982140-4090956935-1935414389-500:/home/Administrator:/bin/bash
Guest:unused:501:513:U-gordito\Gość,S-1-5-21-580982140-4090956935-1935414389-501:/home/Gość:/bin/bash
Gość:unused:501:513:U-gordito\Gość,S-1-5-21-580982140-4090956935-1935414389-501:/home/Gość:/bin/bash
HomeGroupUser$:unused:1004:513:HomeGroupUser$,U-gordito\HomeGroupUser$,S-1-5-21-580982140-4090956935-1935414389-1004:/home/HomeGroupUser$:/bin/bash
sshd:unused:1006:513:sshd privsep,U-gordito\sshd,S-1-5-21-580982140-4090956935-1935414389-1006:/var/empty:/bin/false
cyg_server:unused:1007:513:Privileged server,U-gordito\cyg_server,S-1-5-21-580982140-4090956935-1935414389-1007:/var/empty:/bin/false
nano /etc/group
root:S-1-5-32-544:0:
SYSTEM:S-1-5-18:18:
TrustedInstaller:S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464:4294967294:
Administrators:S-1-5-32-544:544:
Administratorzy:S-1-5-32-544:544:
Czytelnicy dzienników zdarzeń:S-1-5-32-573:573:
Guests:S-1-5-32-546:546:
Goście:S-1-5-32-546:546:
IIS_IUSRS:S-1-5-32-568:568:
Users:S-1-5-32-545:545:
Users DCOM:S-1-5-32-562:562:
Użytkownicy:S-1-5-32-545:545:
Użytkownicy DCOM:S-1-5-32-562:562:
Użytkownicy dzienników wydajności:S-1-5-32-559:559:
Użytkownicy monitora wydajności:S-1-5-32-558:558:
Użytkownicy zarządzania zdalnego:S-1-5-32-580:580:
HomeUsers:S-1-5-21-580982140-4090956935-1935414389-1003:1003:
TelnetClients:S-1-5-21-580982140-4090956935-1935414389-1005:1005:
WinRMRemoteWMIUsers__:S-1-5-21-580982140-4090956935-1935414389-1000:1000:
None:S-1-5-21-580982140-4090956935-1935414389-513:513:
Brak:S-1-5-21-580982140-4090956935-1935414389-513:513:
Only after this, I was finally able to chmod g-rwx all the files that offended sshd, in a way that 'ls -la' indeed confirmed the dropped permissions for group and other.
Then finally, privileged CYGWIN services installed and started (sshd, cron)

How to setup "svnserve --service" to run on Windows?

When starting from cmdline
svnserve.exe -d -r d:\svn\mytools
all working fine.
Then I had tried to set it up to run as Windows service:
#echo off
set SvnHome=C:\Program Files\TortoiseSVN
set SvnRepository=D:\Svn\mytools
sc delete SvnMyTools
sc create SvnMyTools binPath= "%SvnHome%\bin\svnserve.exe --service -r %SvnRepository%" start= delayed-auto type= share
service was installed but it is unable to start.
All the time it is reporting an error
Error 1083: The executable program that this service is configured to run in does not implement the service.
I have tried to edit service cmdline using regedit, so tried to add double quotes arround ref to exe, tried to change cmdline parameters (used -d instead of --service, used both -d and --service) and so on. Sometimes reported errors are looks a bit different but it does not work anyway. :-(
Question is - how to setup it to make it working as service on Windows 7 x64?
Is it possible at all? I mean - if that "--service" cmdline switch is able to work in svnserve?
Note: svnserve version is 1.7.9 (r1462340).
Rest of TortoiseSVN components are 1.7.12.24070.
Thanks in advance.
It took me a while to figure out that the selected answer was not final, but a supplement to the question. This is the final one line command to execute:
sc create svnserve binpath="\"C:\Program Files\TortoiseSVN\bin\svnserve.exe\" --service -r D:\Repositories" displayname="Subversion Server" depend=Tcpip start=auto
Looks fine to me. My server is installed with this binary path:
"C:\Program Files\Subversion\svnserve.exe" --service -r "D:\Repositories" --listen-port "3690"
Did you try to install it outside of a script?
I realize this is an old question, but in case you need to do this on a more current Windows OS version...
On Windows Server 2012 with CollabNet subversion Edge SVN v5.2.4, this syntax worked in an elevated cmd window (NOTE the space after the = character and where the quote " characters are located):
sc create svnserve binpath="E:\csvn\bin\svnserve.exe --service -r E:\csvn\data\repositories --listen-port 3690 --log-file E:\csvn\data\logs\svnserve.log" displayname="SVN Serve" depend= Tcpip start= auto
After creating the svnserve Windows service, to add a description :
sc description svnserve "SVN Server providing the svn:// or svn+ssh:// protocol scheme"
Screenshot of Services.msc showing the newly created svnserve service:
Reference: http://svnbook.red-bean.com/en/1.7/svn.serverconfig.svnserve.html

How to install mongoDB on windows?

I am trying to test out mongoDB and see if it is anything for me. I downloaded the 32bit windows version, but have no idea on how to continue from now on.
I normally use the WAMP services for developing on my local computer. Can i run mongoDB on Wamp?
However, what's the best (easiest!) way to make it work on windows?
Thanks!
Mongo Installation Process in Windows
Are you ready for the installation … and use …
Technically, it’s not an installation it’s just Downloading…
I. Download the zip file http://www.mongodb.org/downloads
II. Extract it and copy the files into your desired location.
III. Start the DB engine.
IV. Test the installation and use it.
That's it! So simple, right? Ok let’s start
1. Download the zip file
Go to http://www.mongodb.org/downloads
You will see a screen like this:
I am using a windows 7 32 bit machine - that’s why I downloaded the package marked in red.
Click download (It only takes a few seconds).
Wow... I got that downloaded. It was a zipped file called mongodb-win32-i386-2.4.4.zip (The name of the folder will change according to the version you download, here I got version 2.4.4).
OK all set.
2. Extract
Extract the zip
Copy the files into a desired location in your machine.
I am going to copy the extracted files to my D drive, since I don’t have many files there.
Alright then where are you planning to paste the mongo files? In C: or in your Desktop itself?
Ok, no matter where you paste... In the snap shot below, you can see that I have navigated to the bin folder inside the Mongo folder. I count fifteen files inside bin. What about you?
Finished! That’s all
What we have to do next?
3. Start the DB engine
Let’s go and start using our mongo db...
Open up a command prompt, then navigate to bin in the mongo folder
Type mongo.exe (which is the command used to start mongo Db Power shell). Then see the below response..
That was an awesome exception J LOL … What is that?
Couldn’t connect to server.
Why did the exception happen? I have no idea... Did I create a server in between?
No.
Right, then how come it connected to a server in between? Silly Machine …Jz.
I got it! Like all other DBs - we have to start the DB engine before we use it.
So, how can we start it?
We have to start the mongo db by using the command mongod. Execute this from the bin folder of mongo.
Let’s see what had happened.
Again a wonderfully formatted exception J we got right? Did you notice what I have highlighted on top? Yeah it is the mongod command. The second one is the exception asking us to create a folder called data. And, inside the data folder, a folder called db.
So we have to create these data\db folders.
The next question is where to create these folders?
We have to create the data\db folders in the C drive of our BOX in which we are installing mongo. Let’s go and create the folder structure in C drive.
A question arises here: "Is it mandatory to create the data\db directories inside C?" Nooo, not really. Mongo looks in C by default for this folder, but you can create them wherever you want. However, if it's not in C, you have to tell mongo where it is.
In other words, if you don't want the mongo databases to be on C:\, you have to set the db path for mongo.exe.
Optional
Ok, I will create those folders in some other location besides C for better understanding of this option. I will create then in the D drive root, with the help of cmd.
Why? Because it’s an opportunity for us to remember the old dos commands...
The next step is to set the Db path to mongo.exe.
Navigate back to bin, and enter the command, mongod.exe --dbpath d:\data.
I got the response below:
I Hope everything went well... Because I didn’t see any ERROR *** in the console J.
Next, we can go and start the db using the command start mongo.exe
I didn't see any error or warning messages. But, we have to supply a command to make sure mongo is up and running, i.e. mongod will get a response:
Hope everything went well.
4. Test the Mongo DB installation
Now we have to see our DB right? Yea very much, Otherwise how will we know it’s running?
For testing purpose MONGO has got a DB called test by default. Lets go query that.
But how without any management studios? Unlike SQL, we have to depend on the command prompt. Yes exactly the same command prompt… our good old command prompt… Heiiiii.. Don’t get afraid yes it’s our old command prompt only.
Ok let’s go and see how we are going to use it…
Ohhh Nooo… don’t close the above Command prompt, leave it as it is…
Open a new cmd window.
Navigate to Bin as usual we do…
I am sure you people may be remembering the old C programming which we have done on our college day’s right?
In the command prompt, execute the command mongo or mongo.exe again and see what happens.
You will get a screen as shown below:
I mentioned before that Mongo has got a test db by default called test, try inserting a record into it.
The next question here is "How will we insert?" Does mongo have SQL commands? No, mongo has got only commands to help with.
The basic command to insert is
db.test.save( { KodothTestField: ‘My name is Kodoth’ } )
Where test is the DB and .save is the insert command. KodothTestField is the column or field name, and My name is Kodoth is the value.
Before talking more let’s check whether it’s stored or not by performing another command: db.test.find()
Our Data got successfully inserted … Hurrayyyyyy..
I know that you are thinking about the number which is displayed with every record right called ObjectId. It’s like a unique id field in SQL that auto-increments and all. Have a closer look you can see that the Object Id ends with 92, so it’s different for each and every record.
At last we are successful in installing and verifying the MONGO right. Let’s have a party...
So do you agree now MONGO is as Sweet as MANGO?
Also we have 3rd party tools to explore the MONGO. One is called MONGO VUE. Using this tool we can perform operations against the mongo DB like we use Management studio for SQL Server.
Can you just imagine an SQL server or Oracle Db with entirely different rows in same table? Is it possible in our relational DB table? This is how mongo works. I will show you how we can do that…
First I will show you how the data will look in a relational DB.
For example consider an Employee table and a Student table in relational way. The schemas would be entirely different right? Yes exactly…
Let us now see how it will look in Mongo DB. The above two tables are combined into single Collection in Mongo…
This is how Collections are stored in Mongo. I think now you can feel the difference really right?
Every thing came under a single umbrella. This is not the right way but I just wanted to show you all how this happens that’s why I combined 2 entirely different tables in to one single Collection.
If you want to try out you can use below test scripts
***********************
TEST INSERT SCRIPT
*********EMPLOYEE******
db.test.save( { EmployeId: "1", EmployeFirstName: "Kodoth", EmployeLastName:"KodothLast", EmployeAge:"14" } )
db.test.save( { EmployeId: "2", EmployeFirstName: "Kodoth 2", EmployeLastName:"Kodoth Last2", EmployeAge:"14" } )
db.test.save( { EmployeId: "3", EmployeFirstName: "Kodoth 3", EmployeLastName:"Kodoth Last3", EmployeAge:"14" } )
******STUDENT******
db.test.save( { StudentId: "1", StudentName: "StudentName", StudentMark:"25" } )
db.test.save( { StudentId: "2", StudentName: "StudentName 2", StudentMark:"26" } )
db.test.save( {StudentId: "3", StudentName: "StudentName 3", StudentMark:"27"} )
************************
Thanks
It's not like WAMP. You need to start mongoDB database with a command after directory has been created C:/database_mongo
mongod --dbpath=C:/database_mongo/
you can then connect to mongodb using commands.
Pretty good documentation is provided on the MongoDB website
Install MongoDB
Determine which MongoDB build you need.
There are three builds of MongoDB for Windows:
MongoDB for Windows Server 2008 R2 edition (i.e. 2008R2) runs only on Windows Server 2008 R2, Windows 7 64-bit, and newer versions of
Windows. This build takes advantage of recent enhancements to the
Windows Platform and cannot operate on older versions of Windows.
MongoDB for Windows 64-bit runs on any 64-bit version of Windows newer than Windows XP, including Windows Server 2008 R2 and Windows 7
64-bit.
MongoDB for Windows 32-bit runs on any 32-bit version of Windows newer than Windows XP. 32-bit versions of MongoDB are only intended
for older systems and for use in testing and development systems.
32-bit versions of MongoDB only support databases smaller than 2GB.
To find which version of Windows you are running, enter the following command in the Command Prompt:
wmic os get osarchitecture
Download MongoDB for Windows.
Download the latest production release of MongoDB from the MongoDB downloads page. Ensure you download the correct version of MongoDB for
your Windows system. The 64-bit versions of MongoDB does not work with
32-bit Windows.
Install the downloaded file.
In Windows Explorer, locate the downloaded MongoDB msi file, which typically is located in the default Downloads folder. Double-click the
msi file. A set of screens will appear to guide you through the
installation process.
Move the MongoDB folder to another location (optional).
To move the MongoDB folder, you must issue the move command as an Administrator. For example, to move the folder to C:\mongodb:
Select Start Menu > All Programs > Accessories.
Right-click Command Prompt and select Run as Administrator from the popup menu.
Issue the following commands:
cd \
move C:\mongodb-win32-* C:\mongodb
MongoDB is self-contained and does not have any other system dependencies. You can run MongoDB from any folder you choose. You may
install MongoDB in any folder (e.g. D:\test\mongodb)
Run MongoDB
Warning:
Do not make mongod.exe visible on public networks without running in
“Secure Mode” with the auth setting. MongoDB is designed to be run in
trusted environments, and the database does not enable “Secure Mode”
by default.
Set up the MongoDB environment.
MongoDB requires a data directory to store all data. MongoDB’s default data directory path is \data\db. Create this folder using the
following commands from a Command Prompt:
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"
Start MongoDB.
To start MongoDB, run mongod.exe. For example, from the Command Prompt:
C:\Program Files\MongoDB\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.
Depending on the security level of your system, Windows may pop up a Security Alert dialog box about blocking “some features” of
C:\Program Files\MongoDB\bin\mongod.exe from communicating on
networks. All users should select Private Networks, such as my home or
work network and click Allow access. For additional information on
security and MongoDB, please see the Security Documentation.
Connect to MongoDB.
To connect to MongoDB through the mongo.exe shell, open another Command Prompt. When connecting, specify the data directory if
necessary. This step provides several example connection commands.
If your MongoDB installation uses the default data directory, connect without specifying the data directory:
C:\mongodb\bin\mongo.exe
If you installation uses a different data directory, specify the directory when connecting, as in this 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"
If you want to develop applications using .NET, see the documentation of C# and MongoDB for more information.
Begin using MongoDB.
To begin using MongoDB, see Getting Started with MongoDB. Also consider the Production Notes document before deploying MongoDB in a
production environment.
Later, to stop MongoDB, press Control+C in the terminal where the mongod instance is running.
Configure a Windows Service for MongoDB
Note:
There is a known issue for MongoDB 2.6.0, SERVER-13515, which prevents
the use of the instructions in this section. For MongoDB 2.6.0, use
Manually Create a Windows Service for MongoDB to create a Windows
Service for MongoDB instead.
Configure directories and files.
Create a configuration file and a directory path for MongoDB log output (logpath):
Create a specific directory for MongoDB log files:
md "C:\Program Files\MongoDB\log"
In the Command Prompt, create a configuration file for the logpath option for MongoDB:
echo logpath=C:\Program Files\MongoDB\log\mongo.log > "C:\Program Files\MongoDB\mongod.cfg"
Run the MongoDB service.
Run all of the following commands in Command Prompt with “Administrative Privileges:”
Install the MongoDB service. For --install to succeed, you must specify the logpath run-time option.
"C:\Program Files\MongoDB\bin\mongod.exe" --config "C:\Program Files\MongoDB\mongod.cfg" --install
Modify the path to the mongod.cfg file as needed.
To use an alternate dbpath, specify the path in the configuration file (e.g. C:\Program Files\MongoDB\mongod.cfg) or on the command line
with the --dbpath option.
If the dbpath directory does not exist, mongod.exe will not start. The default value for dbpath is \data\db.
If needed, you can install services for multiple instances of mongod.exe or mongos.exe. Install each service with a unique
--serviceName and --serviceDisplayName. Use multiple instances
only when sufficient system resources exist and your system design
requires it.
Stop or remove the MongoDB service as needed.
To stop the MongoDB service use the following command:
net stop MongoDB
To remove the MongoDB service use the following command:
"C:\Program Files\MongoDB\bin\mongod.exe" --remove
Manually Create a Windows Service for MongoDB
The following procedure assumes you have installed MongoDB using the
MSI installer, with the default path C:\Program Files\MongoDB 2.6
Standard.
If you have installed in an alternative directory, you will need to
adjust the paths as appropriate.
Open an Administrator command prompt.
Windows 7 / Vista / Server 2008 (and R2)
Press Win + R, then type cmd, then press Ctrl + Shift + Enter.
Windows 8
Press Win + X, then press A.
Execute the remaining steps from the Administrator command prompt.
Create directories.
Create directories for your database and log files:
mkdir c:\data\db
mkdir c:\data\log
Create a configuration file.
Create a configuration file. This file can include any of the configuration options for mongod, but must include a valid setting for
logpath:
The following creates a configuration file, specifying both the logpath and the dbpath settings in the configuration file:
echo logpath=c:\data\log\mongod.log> "C:\Program Files\MongoDB 2.6 Standard\mongod.cfg"
echo dbpath=c:\data\db>> "C:\Program Files\MongoDB 2.6 Standard\mongod.cfg"
Create the MongoDB service.
Create the MongoDB service.
sc.exe create MongoDB binPath= "\"C:\Program Files\MongoDB 2.6 Standard\bin\mongod.exe\" --service --config=\"C:\Program Files\MongoDB 2.6 Standard\mongod.cfg\"" DisplayName= "MongoDB 2.6 Standard" start= "auto"
sc.exe requires a space between “=” and the configuration values (eg “binPath=”), and a “” to escape double quotes.
If successfully created, the following log message will display:
[SC] CreateService SUCCESS
Start the MongoDB service.
net start MongoDB
Stop or remove the MongoDB service as needed.
To stop the MongoDB service, use the following command:
net stop MongoDB
To remove the MongoDB service, first stop the service and then run the following command:
sc.exe delete MongoDB
I realize you've already accepted an answer for this, but I wrote this short howto article to install mongodb into the c:\wamp directory and run it as a service. Here is the gist of it.
Create these directories
mkdir c:\wamp\bin\mongodb\mongodb-win32...2.x.x\data
mkdir c:\wamp\bin\mongodb\mongodb-win32...2.x.x\data\db
mkdir c:\wamp\bin\mongodb\mongodb-win32...2.x.x\logs
mkdir c:\wamp\bin\mongodb\mongodb-win32...2.x.x\conf
Download and extract win32 binaries into c:\wamp directory along side mysql, apache.
mongodb download page
Create a mongo.conf file
c:\wamp\bin\mongodb\mongodb-win32…2.x.x\conf\mongodb.conf
# mongodb.conf
# data lives here
dbpath=C:\wamp\bin\mongodb\mongodb-win32...2.x.x\data\db
# where to log
logpath=C:\wamp\bin\mongodb\mongodb-win32...2.x.x\logs\mongodb.log
logappend=true
# only run on localhost for development
bind_ip = 127.0.0.1
port = 27017
rest = true
Install as a service
mongod.exe --install --config c:\wamp\bin\mongodb\mongodb-win32...2.x.x\conf\mongodb.conf --logpath c:\wamp\bin\mongodb\mongodb-win32...2.x.x\logs\mongodb.log
Set service to automatic and start it using services.msc
Add path to mongo.exe to your path
Need more details? Read the full article here...
Installing MongoDB on Windows the WAMP way
1. Download MongoDB
2. Install MongoDB
3. Create the required folders:
"C:\MongoDB_2_6_Standard\bin\data\db"
"C:\MongoDB_2_6_Standard\logs"
"C:\MongoDB_2_6_Standard\etc"
NOTE: If the directories do not exist, mongod.exe will not start.
4. Create a simple configuration file:
systemLog:
destination: file
path: C:\MongoDB_2_6_Standard\logs\mongo.log
logAppend: true
net:
bindIp: 127.0.0.1
port: 27017
More info about how to create a configuration file: http://docs.mongodb.org/manual/reference/configuration-options/
5. Install MongoDB as a Windows Service (this way it will start automatically when you reboot your computer)
Run cmd with administrator privilegies, and enter the following commands:
"C:\MongoDB_2_6_Standard\bin\mongod.exe" --config "C:\MongoDB_2_6_Standard\etc\mongodb.conf" --dbpath c:\MongoDB_2_6_Standard\bin\data\db --directoryperdb --install
6. Start the MongoDB Windows Service
net start MongoDB
7. Connect to MongoDB via shell/cmd for testing
C:\MongoDB_2_6_Standard\bin\mongo.exe
NOTE: http://docs.mongodb.org/manual/tutorial/getting-started-with-the-mongo-shell/
8. That's it! You are done. :)
9. Uninstall/remove the MongoDB Windows Service (if you messed up something)
"C:\MongoDB_2_6_Standard\bin\mongod.exe" --remove
Step by Step Solution for windows 32 bit
Download msi file for windows 32 bit.
Double click Install it, choose custom and browse the location where ever you have to install(personally i have create the mongodb folder in E drive and install it there).
Ok,now you have to create the data\db two folder where ever create
it, i've created it in installed location root e.g on
E:\
Now link the mongod to these folder for storing data use this
command or modify according to your requirement go to using cmd
E:\mongodb\bin and after that write in console
mongod --dbpath E:\data it will link.
Now navigate to E:\mongodb\bin and write mongod using cmd.
Open another cmd by right click and run as admin point to your
monogodb installed directory and then to bin just like
E:\mongodb\bin and write this mongo.exe
Next - write db.test.save({Field:'Hello mongodb'}) this command
will insert the a field having name Field and its value Hello
mongodb.
Next, check the record db.test.find() and press enter you will find
the record that you have recently entered.
Its very simple to install Mongo DB on windows 7 ( i used 32 bit win7 OS)
Install the correct version of Mongodb ( according to ur bit 32/64 .. imp :- 64 bit is not compatible with 32 bit and vice versa)
2.u can install Mongodb from thius website ( acc to ur OS) http://www.mongodb.org/downloads?_ga=1.79549524.1754732149.1410784175
DOWNLOAD THE .MSI OR zip file .. and install with proper privellages
4.copy the mongodb folder from c:programfiles to d: [optional]
5.After installation open command prompt ( as administrator .. right click on cmd and u will find the option)
navigate to D:\MongoDB 2.6 Standard\bin
run mongo.exe ... you might get this error
If you get then no isse you just need to do following steps
i) try the coomand in following image yo will get to know the error
ii)This means that u neeed to create a directory \data\db
iii) now you have two options either create above directory in c drive or create any "xyz" name directory somewhere else ( doesnot make and diffrence) .. lets create a directory of mongodata in d:
Now lets rerun the command but now like this :- mongod --dbpath d:\mongodata [shown in fig]
this time you will not get and error
Hope everything is fine till this point .. open new command propmt [sufficent privellages (admin)]
colured in orange will be the command u need to run .. it will open the new command propmt which we known as mongo shell (or mongodb shell)
11.dont close the shell[any of command promt as well] as in this we will create /delete/insert our databse operations
Lets perform basic operation
a) show databases
b) show current databse
c) creation of collection / inserting data into it (name will be test)
d) show data of collection
12.please find scrren shot of results of our operation .. please not :- dont close any command propmt
a diffrent structure type of number is object id :- which is created automatically
Hope you get some important info for installing mongodb DB.
Installing MongoDB on Windows is bit tricky compared to other Executable files.. Got a good reference after long search i got Installing MongoDB in Windows
After Installing open command prompt and type "mongod", then keep the window minimized and open another command prompt window and type "mongo" and you will find the success message of connecting to the test database
Update Nov -2017
1) Go to Mongo DB download center https://www.mongodb.com/download-center#community and pick a flavor of MongoDB you want to install. You can pick from
MongoDB Atlas - MongoDB database in the cloud
Communiy Server - MongoDb for windows (with and without SSL),iOS, Linux
OpManger- Mongo Db for Data Center
Compass - UI tool for MongoDB
To know your OS version run this command in cmd prompt
wmic os get caption
To know your CPU architecture(32 or 64 bit) run this command in cmd prompt
wmic os get osarchitecture
I am using Community version (150MBs- GNU license)
2) Click on MSI and go through installation Process. Exe will install MongoDb and SSL required by the DB.
Mongo DB should be installed on your C drive
C:\Program Files\MongoDB
MongoDB is self-contained, it means and does not have any other system dependencies. If you are low on disk in C drive then you can run MongoDB from any folder you choose.
You can now run mongodb.exe from bin folder. If you get Visual C++ error for missing dlls then download Visual C++ Redistributable from
https://www.microsoft.com/en-in/download/details.aspx?id=48145
After installation, try to rerun mongo.exe.
You might want to check https://github.com/Thor1Khan/mongo.git
it uses a minimal workaround the 32 bit atomic operations on 64 bits operands
(could use assembly but it doesn't seem to be mandatory here)
Only digital bugs were harmed before committing
Download .msi from https://www.mongodb.com/download-center#community
Double click install - complete option
Installation folder C:\Program Files\MongoDB\Server\3.6\bin
Create database folder in C:// - c:/data/db and c:/data/log and c:/data/log/mongo.log and set write permission if not
Open cmd prompt in Administrator mode , navigate to C:\Program Files\MongoDB\Server\3.6\bin
Type the following
C:\Program Files\MongoDB\Server\3.6\bin>mongod --dbpath="c:/data/db" --logpath="c:/data/log/mongo.log"
Check folder c:/data/db - there should be many files and folder
Create a config file named "mongo.config" ** inside C:\data\
Type the following to set the config values from newly created config file
C:\Program Files\MongoDB\Server\3.6\bin>mongod --config C:\data\mongo.config
Open another new cmd prompt in Administrator mode , navigate to C:\Program Files\MongoDB\Server\3.6\bin
execute the following lines on the console.
Type the following to create service for MongoDB
C:\Program Files\MongoDB\Server\3.6\bin>mongod --install --config C:\data\mongo.config --logpath="c:/data/log/mongo.log"
If old MongoDB service exists then need to delete the old service first before mongod --install command, run the following in a new console to delete old mongodb service
SC STOP MongoDB
>> SC DELETE MongoDB
Type the following to start MongoDB
C:\Program Files\MongoDB\Server\3.6\bin>net start MongoDB
Type the following to stop MongoDB
C:\Program Files\MongoDB\Server\3.6\bin>net stop MongoDB
Now connect the DB on ip - 127.0.0.1 or 192.168.5.64 on port 27017 .
** File name - "mongo.config" , paste the following on config file -
bind_ip = 127.0.0.1,192.168.5.64
port = 27017
dbpath=C:\data\db
logpath=C:\data\log\mongo.log
Install MongoDB Community Edition for Windows.
1.Now go to Download Center.
The Download Center should display the Current Stable Release for Windows
Click Download (msi) and run it
When you go through You can choose either the Complete or Custom setup type. Select Complete Setup.
Starting MongoDB server from the Command Prompt
1.Add this path to environmental variables
“C:\ProgramFiles\MongoDB\Server\4.0\bin” For those who struggle to setup environmental variable please follow this steps
Windows 10 and Windows 8
In Search, search for and then select: System (Control Panel)
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables, find
the PATH environment variable and select it. Click Edit.
If the PATH environment variable does not exist, click New.
In the Edit System Variable (or New System Variable) window, specify
the value of the PATH as
“C:\ProgramFiles\MongoDB\Server\4.0\bin”environment variable.
Click OK.
Close all remaining windows by clicking OK.
Now create MongoDB Data Directory MongoDB requires a data directory to store all data. Open Command Prompt and paste below
md "C:\data\db" "C:\data\log"
3.Lets point server to your database directory.Type below code
mongod --dbpath="c:\data\db"
4.Now lets connect to MongoDB Type below code
mongo
5.If it is working properly Command prompt will show
[initandlisten] waiting for connections
Bingo!! You are done, Apparently it is bit confusing to use CLI, well MongoDB introduced a GUI which you can see the actual data ,
To use mongoDB GUI version Above steps must have been performed
Now go to Download Center. Download MongoDb Compass ,a GUI for MongoDB
Install it and open
You can see the hostname : localhost and port : 27017.
Whenever you wanted to connect to mongoDB Server , You have to open Command prompt
Type
mongod
then again start a new Command prompt and type
mongo
Keep ‘em all settings as it is in mongoDB Compass. Now click connect ,
You are in !! Easy .. isn’t it?
Download from http://www.mongodb.org/downloads
Install .msi file in folder C:\mongodb
Create data, data\db, log directories and mongo.config file under C:\mongodb.
Add the following lines in
"mongo.config" file dbpath=C:\mongodb\data\db\
logpath=C:\mongodb\log\mongo.log
Start server :
mongod.exe --config="C:\mongodb\mongo.config"
That's it !!!
Step 1: First download the .msi i.e is the installation file from
Download MonggoDB
Step 2: Perform the installation using the so downloaded .msi file.Automatically it gets stored in program files. You could perform a custom installation and change the directory.
After this, you should be able to see a MongoDB folder under program files
starting MongoDB shell and service is not big a deal I Got a good reference after the long search Installing MongoDB in Windows
WAMP = Windows + Apache + MySQL/MariaDB + PHP/Python/Perl
You can't use MongoDB in wamp.You need to install MongoDB separately

Resources