Download
The easiest way to install MongoDB is to use compiled binary files.
Note: We recommend that you use the 64-bit version (although you must use a 64-bit system to run this version ).
Download 32-bit Binaries
Download 64-bit Binaries
Extract
Decompress the downloaded mechanism file to any location you like. For convenience, You can rename "mongo-xxxxxxx" to "mongo ".
Create a data directory
: MongoDB stores data in the \ data \ dB directory by default, but it does not automatically create this folder. So we do this:
CMD code
- C: \> mkdir \ data
- C: \> mkdir \ data \ DB
You can also use the resource manager.
.If you want to save the data file to another location, use the -- dbpath command line parameter when logging on to mongod.exe.
Run and connect to the server
There are two important files when you start running:
DB code
- Mongod.exe-database server. You can use mongod-help to view the startup options.
- Cmd.exe-Administrator command line.
To run the data warehouse, open mongod.exe from the Resource Manager window.
CMD code
- C: \> CD \ my_1__dir \ bin
- C: \ my_1__dir \ bin> mongod
Note: This server can also be run as a Windows service. We will introduce it later.
Now, open the Administrator command line (double-click from the resource manager or use the CMD window ). In other regions, cmd.exe runs on localhost to connect to a mongod server and uses the test database. You can run mongo-help to view other options.
CMD code
- C: \> CD \ my_1__dir \ bin
- C: \ my_1__dir \ bin> Mongo
JS Code
- > // The Mongo shell is a javascript shell connected to the DB
- > // By default it connects to database 'test' at localhost
- > 3 + 3
- 6
- > DB
- Test
- > // The first write will create the DB:
- > DB. Foo. insert ({A: 1 })
- > DB. Foo. Find ()
- {_ ID:..., A: 1}
- > Show DBS
- ...
- > Show collections
- ...
- > Help
Congratulations, you have saved and retrieved your first MongoDB document!
Programming
You can use MongoDB to virtualize programs in any programming language. Go to the drivers page to view the list of all languages. If you want to write a. Net program, you can view the information on the C # page.