Download
Download MongoDB, naturally in his official website to download the corresponding version of the system, I downloaded the Windows installation package.
Installation
Fool-mounted, not much to say. (Installed on the C drive by default.) )
Start
MongoDB data exists in a data
folder called folders, this folder is created by itself:
$ cd c:/$ mkdir data$ cd data$ mkdir db$ mkdir log
Now it's time to start MongoDB.
The command line enters the bin folder of the MongoDB installation directory. Run the command:
$ mongod dbpath "C:\data\db" --logpath "C:\data\log\mongodb.log"
The boot was successful without an accident.
However, when the command window is closed, MongoDB is also closed, which is not interesting.
So the MongoDB setting becomes the service of the system.
shell $ mongod --dbpath "C:\data\db" --logpath "C:\data\log\mongodb.log" --serviceName "MongoDB" --install
This step, tried several times, you must run Cmd.exe as an administrator, and then execute the following command:
shell $ net start MongoDB
No accident, the MongoDB service started successfully.
Access
Now boot also started, how to operate the database?
The MongoDB installation directory under the Bin folder has one mongo.exe
, as long as the command line to run this file is good:
$ cd C:\Program Files\MongoDB\Server\3.6\bin$ mongo
But it is not always possible to access the database every time you have to go into this folder, so C:\Program Files\MongoDB\Server\3.6\bin
add to the system's PATH environment variable is good.
So, it's done!!!
Installation of MongoDB on Windows