I Want to install MongoDB and start it,I used this codes in cmd
mongod --directoryperdb --dbpath C:\mongodb\data\db --logpath C:\mongodb\log\mongo,log --logappend --rest --install
And For start this used this code in cmd net start MongoDB But I give this Error
The service name is invalid.
More help is available by typing NET HELPMSG 2185.
How I Can fixed it?I'm searching any more time But don't find any Solution
The problem is, the MongoDB service isn't installed, because you executed the install command without admin privilegues.
To solve this, open the start menu, enter powershell, right-click and select run as administrator. Now you should be able to run the install command.
mongod --directoryperdb --dbpath C:\mongodb\data\db --logpath C:\mongodb\log\mongo.log --logappend --rest --install
If you encounter the error again, after you tried to install the service as an admin user, you should have a look at the log file (in your case C:\mongodb\log\mongo.log)
Btw. there was an typo in your command for the logfile name (command instead of point for the filename)
Related
I just installed a new MongoDB 3.6 on my Windows machine. Now I'm trying to change the default DB path. So I tried this:
"C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe" --dbpath c:\mongodb\data
It worked, but only until I restarted Mongo. Then it was back to usual c:\data\db.
I tried to google it, saw some info about changing a mongod.conf file, but I can't find this file in my installation.
Any suggestions?
Save this script in a Batch File(Mongo.bat) and run it every time:
"C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe" --dbpath c:\mongodb\data
You need to start mongod with same command everytime:
C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe" --dbpath c:\mongodb\data
Or you can create a configuration file and install mongo as a service.
.
After installing mongodb on windows, I set up the necessary folders but made a typing mistake when doing the following command:
mongod --directoryperdb --dbpath C:\mondodb\data\db --logpath C:\mongodb\log\mongo.log --logappend --rest --install
the folder is named mongodb but i named it mondodb by accident and can't seem to overwrite that, so when I start mongodb by doing net start mongodb I get an error in my log saying C:\mondodb\data\db not found
I tried redoing it like so mongod --directoryperdb --dbpath C:\mongodb\data\db --logpath C:\mongodb\log\mongo.log --logappend --rest --install but it's not working.
how can I redo the mongod thingy?
There are a few different things you could try:
Go into the registry and change the service path: Modifying the "Path to executable" of a windows service. After you modify it, you can go into Services.msc, right-click on the service, go to Properties, then Look at the Path to executable: and make sure that it points to mongodb rather than mondodb.
It involves editing the registry, but service information can be found in HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services. Find the service you want to redirect, locate the ImagePath subkey and change that value.
Go into a command prompt (may need to Run as Administrator) and do sc delete mongod <or whatever the service is named> -- can check services.msc for that). Then re-run your command with the correct path.
Alternately, you might try to set it up by taking a config file so that you can just change those options via config file rather than having to modify the service or delete/reinstall the service when you want to change options. I believe the command there is C:\<mongopath>\mongod.exe -f <config file name> --install.
I've just downloaded mongodb 3.2 version and went through the installtion using mongodb manual.
My mongodb directory is in c:\mongodb\.
When I try to run net start MongoDB command using cmd in superuser mode
it says :
system error 2 has occurred.
the system cannot find the file specified.
Try to remove mongoDB as a service first before installing it again if you are not using MongoDB for the first time.
mongod --remove
then install mongoDB service again in your own mongoDB folder.
mongod --directoryperdb --dbpath C:\mongodb\data\db --logpath C:\mongodb\log\mongo.log --logappend --rest --install
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
I am new to cygwin. I just installed v1.7.25(0.270/5/3) on my win7 machine. When I invoke mongod with
--fork [mongod --configsvr --dbpath cfg2 --port 26052 --logpath log.cfg2 --logappend]
it say :
"error command line: unknown option fork".
What I understand is that --fork is a linux or unix command not necessarily a mongod command. So how to make it work in cygwin on windows? On the other hand, is the problem happening because windows installation of mongod cannot do --fork? I am confused here, pls help!!!
Fork as a configuration option is not supported by the windows version of mongodb. So if you downloaded the windows binary, it will not be able to use the --fork option to run in the background of your shell. If you run mongod --help, the --fork option shouldn't appear. If you want, you can still start mongod from cygwin, but you'll need to use the windows command line to do it.
If your ultimate goal is to get you database process running in the background, in Windows the way to do this is to set up mongodb as a service: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/#mongodb-as-a-windows-service