Entry-Level MongoDB

Source: Internet
Author: User
Tags install mongodb install mongodb windows mongodb windows mongo shell

Thanks for the reprint.

(1) Download MongoDB

Window version: Http://www.mongodb.org/dr/downloads.mongodb.org/win32/mongodb-win32-i386-1.8.3.zip/download

(2), Set up MongoDB directory (unzip zip file) unzip it to D:\, rename it to MongoDB, path to D:\mongodb (3), set data file path in D: Set up a DB folder, path D:\mongodb\db. before starting the MongoDB service, you need to create a storage folder for the database files, otherwise the command will not be created automatically and cannot start successfully. The default folder path is C:/ When the default folder path starts, the service does not need to add the--dbpath parameter description, but the folder also has to be created manually

(4), start MongoDB service into CMD prompt console, D:\mongodb\bin\mongod.exe--dbpath=d:\mongodb\db

Show:

Console code
  1. Microsoft Windows [version 6.1. 7600]
  2. Copyright (c) Microsoft Corporation.  All rights reserved.
  3. D:\>CD Developtools
  4. D:\DEVELOPTOOLS>CD MongoDB
  5. D:\DEVELOPTOOLS\MONGODB>CD bin
  6. D:\developtools\mongodb\bin>mongod.exe--dbpath=d:\developtools\mongodb\data
  7. Mon Sep ::[Initandlisten] MongoDB starting:pid=4920 port=27017 dbpat /c2>
  8. H=d:\developtools\mongodb\data 32-bit
  9. * * Note:when using MongoDB + bit, you is limited to about 2 gigabytes of data
  10. * * See http://blog.mongodb.org/post/137788967/32-bit-limitations
  11. * * with--dur, the limit is lower
  12. Mon Sep :[Initandlisten] db version v1. 8.3, pdfile version 4.5
  13. Mon Sep ::[Initandlisten] git version:c206d77e94bc3b65c76681df5a6b605
  14. F68a2de05
  15. Mon Sep ::[initandlisten] Build sys info:windows (5, 1, 2600, 2, ' Ser
  16. Vice Pack 3 ') boost_lib_version=1_35
  17. Mon Sep ::[Initandlisten] waiting for connections on port 27017
  18. Mon Sep ::[websvr] Web admin interface listening on port 28017

Indicates a successful start, the last two lines of the database port and the Web port, the default is 27017 and 28017, in the browser open http://localhost:28017, you can see some information about it.

You can modify the database port by adding the parameter--port: D:/mongodb/bin>mongod.exe--port 10001--dbpath d:/mongodb/data/db

5. Open a cmd input: D:/mongodb/bin>mongo, or double-click Mongo.exe, you can do the client command operation of MongoDB, under test

>//The MONGO shell is a JavaScript shell connected to the DB
> 3+3
6
> DB
Test
> //The first write would create the DB:
> Db.foo.insert ({a:1})
> Db.foo.find ()
{_id: ..., a:1}

(5), the MongoDB as Windows services randomly started . Like the above operation every time MongoDB is inconvenient, we can like the installation of MySQL, as the Windows service, so much more convenient.

The way to install MongoDB Windows Services is to create the logs directory under the MongoDB installation directory and then enter it on the cmd command line
E:/mongodb/bin>mongod--logpath D:/mongodb/logs/mongodb.log--logappend

--dbpath d:/mongodb/data/db--directoryperdb--servicename MongoDB--install

Show:

All output Going To:d:/mongodb/logs/mongodb.log
Creating service MongoDB.
Service creation successful.
Service can is started from the command line via ' net start ' MongoDB '.

Indicates that the service was created successfully.

The command line specifies the log file:/logs/mongodb.log, the log is output in an append manner;

Data file directory:/data/db, and the parameter--directoryperdb indicates that each DB will create a new directory;

Name of the Windows service: MongoDB;

The above three parameters can be determined according to their own circumstances.

Finally, the installation parameters:--install, the opposite is--remove

(6) You can start and stop MongoDB under cmd with command net start MongoDB and net stop MongoDB, or you can see in the Local service Span style= "Font-size:small;" > Manage the service through the interface.

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.