NET you will want to start with the Official MongoDB C# driver NuGet package. When you are ready to deploy to production, you will need to set up security and replication.įor development in. It does not require authentication, but is not exposed on the network, only through 127.0.0.1. You now have a MongoDB development server running on your local system. If you ever want to uninstall the service, the command is, sc.exe delete MongoDB Next Steps You can now start and stop the service with the following commands, net start MongoDB Not sure if this is relevant, but for background I am accessing the same DB from a laptop (same versions of MongoDB and Windows10), not at the same time (), so that I can do development work at home or when away.
#Running mongodb as a service windows Pc
You should then see, CreateService SUCCESS Hi I have been using MongoDB Community edition (version mongodb-win32-x8664-2012plus-4.2.5-signed) on my PC until yesterday, running Windows 10. Now run the command, sc.exe create MongoDB binPath="C:\MongoDB\bin\mongod.exe -service -config=C:\MongoDB\mongod.cfg" DisplayName="MongoDB 2.6 Standard" start="auto" On Windows 7, press WIN+R, then type cmd, them press CTRL+SHIFT+ENTER.
#Running mongodb as a service windows install
We now know that our configuration is correct, so now I want to install it as a service so that it is always running, T14:28:36.579-0400 warning: Failed to connect to 127.0.0.1:27017, reason: errno:10061 No connection could be made because the target machine actively refused it. I am shutting the server down while I am connected to it, thus the errors.
![running mongodb as a service windows running mongodb as a service windows](https://i.stack.imgur.com/6Pfmk.png)
Then in another command window, connect to the running server to make sure it is up and running. Start it at the command prompt like this, C:\MongoDb\bin>mongod.exe -f. Now that I have it set up, it is time to test the installation. For more configuration options, see the documentation.
![running mongodb as a service windows running mongodb as a service windows](https://storage.googleapis.com/static.configserverfirewall.com/images/mongodb/download-mongodb-windows.png)
Notice that I am only binding to 127.0.0.1 because my server is currently insecure so I do not want to expose it on the network.
![running mongodb as a service windows running mongodb as a service windows](https://i1.wp.com/www.dark-hamster.com/wp-content/uploads/2020/12/01-type-service-field.png)
This sets the log and the db path and also sets the port to the default so it is easy to change later. Your directory structure should now look like this, c:\mongodbĪdd a text file called c:\MongoDB\mongod.cfg that contains the following, systemLog: The bin subdirectory should already be there. In the MongoDB directory, create a data subdirectory and in it add db and log subdirectories. The MSI installs into Program Files, but I prefer to keep the binaries and the databases together and not have to run as an Admin. For windows, I prefer the 64-bit Zip file. Install MongoDBĭownload MongoDB from their website. Getting it setup and running on a development box is easy, but I wanted to document the steps for reference.