Learn MongoDB one: Getting Started with MongoDB (Installation and configuration)

Source: Internet
Author: User
Tags install mongodb

A. Brief introduction???

? ? MongoDB is a non-relational database (NOSQL). is a powerful, flexible, and scalable way to store data. Because MongoDB is a document model, free and flexible is very high, can make you in the development process is very smooth, for large data volume, high concurrency, weak transactions of the Internet applications. MongoDB is able to handle it, and MongoDB's built-in horizontal scaling mechanism provides the ability to handle data volumes from millions to 1 billion levels, support for MapReduce aggregation, and support for geospatial indexes.


two. Installation and configuration

1. Download and install

?? http://www.mongodb.org/downloads

? My system is Windows7 32 bit, so I download the corresponding version number Mongodb-win32-i386-2.6.8.zip

? ??

2. Installation and Configuration

? The first step: Extract to a disk, such as my Unpacked folder D:\mongodb, see:

? ??

? Step Two: Configure the folder where the logs and data are stored. Otherwise MongoDB won't start up. What you see:

? ?

?

?? We first execute cmd.exe into the DOS command interface, and then go to the CD D:\mongodb\bin folder, and we next have to configure the files for the folder where the logs and data are stored, and we can see which commands we see through the help command:

? ?

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvy29uz2nvbmc2oa==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "/>

??

? We found it. (1)--logpath Arg:arg is the path where the log is set (2)--dbpath Arg:arg is the path where the data file is stored

? Configure the Data folder first, such as I want to store in D:\mongodb\data\db this folder. We are executing cmd.exe into the DOS command interface and then go to the CD D:\mongodb\bin folder, execute the mongod.exe command, and see:

? ??

??

Note: the error is due to the need for us to manually create the D:\mongodb\data\db file path, we create a good path in the execution once, this time success, see:

? ?

? ?

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvy29uz2nvbmc2oa==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "/>

?? Configure the log path, for example, I want to store in D:\mongodb\data\log This folder, we are executing cmd.exe into the DOS command interface, and then into the Cdd:\mongodb\bin folder, Execute the mongod.exe command Mongod.exe--logpath=d:\mongodb\data\log\mongodb.log, as you can see:

? ??

?

?The third step: test whether the configuration is normal

? We are executing cmd.exe into the DOS command interface and then go to the CD D:\mongodb\bin folder. Execute the MONGO command and test the connection. What you see:

? ??

Error occurred

? Note: without starting the server, we need to configure mongodbserver ourselves. We create a mongodb.config configuration file under the D:\mongodb folder. There are two properties LogPath and DBPath, respectively set values. Is the path we configured just now, as seen in:

? ?

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvy29uz2nvbmc2oa==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "/>

The Mongod.exe?--config D:\mongodb\mongodb.config to start the mongodbserver,--config option means that the d:\mongodb\ at startup Mongodb.config configuration file Information configuration server.

What you see:

??

? this DOS command interface does not close first, mongodbserver is executing. I opened a DOS command interface in the new, first go to the CD D:\mongodb\bin folder, and then perform the MONGO command to test the link. What you see:

??


This indicates that the configuration was successful.

?

three. Join MongoDB to Windows Service

We will not be able to link MongoDB when we turn off the DOS command interface that executes Mongodbserver. We need to be like MySQL. Join the Windows Service. Then start the service and close the service on the command line so that we can operate and manage the service.

? ? Next we need to put MongoDB to Windows service, the command used is--install Setup to install MongoDB for server to Windows service

?? The first step: Execute the-install, with the administrator's boot cmd, into the DOS command interface, first into the CD D:\mongodb\bin folder. Perform

d:\mongodb\bin>mongod.exe--dbpath=d:\mongodb\data\db--logpath=d:\mongodb\data\log\log.txt?--Install-- ServiceName "MongoDB"? What you see:

? ??

? ?


? Step Two: Start/close MongoDB service

?? Netstart MongoDB Start MongoDB Service

? net stop MongoDB boot MongoDB service

??

Four: Test the MongoDB shell

? The first step: Execute the Cmd.exe and enter the DOS command interface. Go to the CD D:\mongodb\bin folder and execute the MONGO command. Enter the shell and view the database show DBS, see:

? ? ? ? ? ? ? ?

?

?? Step two: Switch and generate the database

??????????????? When you switch the database, assuming the database does not exist, the database is generated directly. Use test: what you see:

? ? ? ? ? ? ? ? ?

?? Step three: Create a set Merge to save the data

??????????????? ??? A collection named Zhengcy is created

??????????????? Db.zhengcy.insert ({username: ' zcy '})

? ? ? ? ? ? ? ??

? Step three: Find all the data in the Zhengcy collection

????????????? Db.zhengcy.find ()

? ? ? ? ? ??

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvy29uz2nvbmc2oa==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "/>







Learn MongoDB one: Getting Started with MongoDB (Installation and configuration)

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.