Getting started with MongoDB in Windows

Source: Internet
Author: User
Tags install mongodb mongo shell

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
  1. C: \> mkdir \ data
  2. 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
  1. Mongod.exe-database server. You can use mongod-help to view the startup options.
  2. Cmd.exe-Administrator command line.

To run the data warehouse, open mongod.exe from the Resource Manager window.

 

CMD code
  1. C: \> CD \ my_1__dir \ bin
  2. 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
  1. C: \> CD \ my_1__dir \ bin
  2. C: \ my_1__dir \ bin> Mongo

 

 

JS Code
  1. > // The Mongo shell is a javascript shell connected to the DB
  2. > // By default it connects to database 'test' at localhost
  3. > 3 + 3
  4. 6
  5. > DB
  6. Test
  7. > // The first write will create the DB:
  8. > DB. Foo. insert ({A: 1 })
  9. > DB. Foo. Find ()
  10. {_ ID:..., A: 1}
  11. > Show DBS
  12. ...
  13. > Show collections
  14. ...
  15. > 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.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.