Download address: https://www.mongodb.com/download-center/community/releases
The latest version I see now is 4 . four . 2, so download: HTTPS :// fastdl . mongodb . org / windows / mongodb – windows – x86_ sixty-four – four . four . two . zip
After downloading, I move and unzip it by myself, and I put it on disk h to H: mongodb
Create the data directory, and create dB and log under the data directory to store the database and log.
establish mongod.cfg The location of the file here is H: mongodb\ mongod.cfg
Write content in it:
systemLog: destination: file path: H:\mongodb\data\log\mongod.log storage: dbPath: H:\mongodb\data\db
Run the command in the CMD window as an administrator:
H:\mongodb\bin\mongod.exe --config "H:\mongodb\mongod.cfg" --install
You can then use the following two commands:
Net start mongodb
Net stop mongodb
You can also find it in my computer management services and applications services.
Command line interaction
After the service is started, in the bin directory mongo.exe Double click directly to open the interactive environment.
To view the current database:
View all databases:
If there is no data in the database, it will not be displayed.
View all collections:
Add, delete, modify and search:
Add a document to the user collection
To view the document:
This one_ ID is the primary key, if not specified when inserting data_ ID, one will be created by default_ Add the ID to the document.
Number of documents to view:
Delete all documents without conditions