mongodb installation, configuration and command creation service

1. Download the 64-bit MSI installation file and double-click to install it.
2. Go directly to the next step: the first option: Complete (full version), install all functions to the C drive by default; the second option Custom (custom), you can choose the installation directory and service. Here we choose Custom:
3. Click the browser configuration path, the installation is complete!
4. Open the bin folder in the MongoDB directory, you will see many exe executable files:
mongo.exe-->client
mongod.exe--->server
Input and output: (mongodump.exe, mongoexport.exe, mongoimport.exe, mongorestore.exe)
data monitoring: (mongostat.exe, mongostop.exe)

5. First, we create a new db folder in the installation directory (F:\MongoDB) as the database storage path, and then specify it with the server file Directory for the database!
6.
(1) Win+R, enter cmd, enter the DOS command window, and then use the cd command to enter the F:\MongoDB:\bin directory, and execute the following command: F:\MongoDB\bin>mongod.exe --dbpath F :\MongoDB\db
will output server-related information, including version, database path, listening port number, database size, etc. If you see this, you have succeeded.
(2) Or enter in the browser: http: //localhost:27017/, you will see the following paragraph,
           It looks like you are trying to access MongoDB over HTTP on the native driver port.
"Try to connect MongoDB over HTTP on the native driver port", it also means that you have successfully configured the server!

After the server configuration is successful, we do not close the server DOS window, otherwise it will not be able to connect!
7. We open another command window, go to F:\MongoDB:\bin, enter the mongo.exe command
to connect to the database, and see the version number means success
8. Add the MongoDB service to the system, and open the administrator command prompt (management Membership)
, create the configuration file mongod.cfg with the following command:
C:\Windows\system32>echo logpath=F:\MongoDB\log\mongod.log> "F:\MongoDB\mongod.cfg"

C:\Windows\ system32>echo dbpath=F:\MongoDB\db>> "F:\MongoDB\mongod.cfg"
9. Okay, the preparations have been completed, let's start the most important step, use the SC command to create the MongoDB service:
   C: \Windows\system32>sc.exe create MongoDB binpath="F:\MongoDB\bin\mongod.exe --service --config=F:\MongoDB\mongod.cfg"

Output: create service success means success
10.
At this point you can start MongoDB from the service and use its service without having to keep another server-side DOS window!
11. Shut down the service and delete
the service Use the following command to close the service:
C:\Windows\system32>net stop MongoDB
12. Use the following command to delete the service:
C:\Windows\system32>sc.exe delete MongoDB



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326491446&siteId=291194637