The mongodbmongod installation command is not an internal or external command.
1: Installation
Go to the official mongodb website http://www.mongodb.org/downloadsto download the 32bitpackage
After decompression, the following files will appear:
Create a mongodb folder in the C: directory of the installed disk and copy the bin folder to the directory. This is equivalent to installing mongodb commands.
To facilitate the startup of mongodb, Add the mongod.exe path to the environment variable, computer-> properties-> advanced system settings-> environment variable, and add the path to the path:
In this way, the mongod command can be used anywhere in the command line.
2. Create and start data files
Create a mongodb folder on disk D to store data files, create data and log folders under the mongodb folder, and create a mongodb. log file under the log folder.
Start mongodb service: Open the command line and enter the command
> Mongod -- dbpath "d: // mongodb // data" -- logpath "d: // mongodb // log // mongodb. log" -- logappend
The following conditions indicate that the port is successfully started on port 27017.
Resolution: The mongod -- dbpath command is used to create the storage location of database files. when starting the mongodb service, you must first determine the location where the database files are stored. Otherwise, the system will not automatically create the database and the startup will fail.
-- Logpath indicates the path where the log file is stored -- logappend indicates that the log file is written as an append.
This information is displayed in the browser:
The default port is 27017. You can also use the -- port command to modify the port, for example, mongod -- port 9888 "d :\\ mongodb \ data"
3: start as a service
You need to enter the preceding command every time you start the service. For convenience, you can write the startup database as a window service.
>Mongod -- logpath "d: // mongodb // log // mongodb. log" -- logappend -- dbpath "d: // mongodb/data" -- directoryperdb -- serviceName MongoDB -- install
In this way, you only need to input net start MongoDB in the command line to start the service, but I don't know why. I set it like this and I cannot find MongoDB in the "service?
Start cmd as an administrator and enter the following command:
SC create mongodb binPath = "c: \ mongodb \ bin \ mongod.exe -- service -- dbpath D: \ mongodb \ data -- logpath = d: \ mongodb \ log \ mongodb. log -- logappend -- directoryperdb"
Delete service command: mongod.exe -- remove -- serviceName "MongoDB"
Note that the command line must be started as an administrator.
In this way, the MongoDB service is available in the service.
In the process of tossing the mongodb service, I found that the database service could not be started, and the pop-up box reported the error "the service has no response or control function". I tried many other methods without any solution.
Finally, execute SC delete mongodb to force delete the mongodb service.