| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx

安装MongoDB 在Windows

1
Lua MongoDB C/C++ Go 16499 次浏览

MongoDB GUI图形化管理工具 JMongoBrowser

Synopsis

This tutorial provides a method for installing and running the MongoDB server (i.e. “mongod.exe”) on the Microsoft Windows platform through the Command Prompt and outlines the process for setting up MongoDB as a Windows Service.

Operating MongoDB with Windows is similar to MongoDB on other platforms. Most components share the same operational patterns.

Procedure

Download MongoDB for Windows

Download the latest production release of MongoDB from the MongoDB downloads page.

There are three builds of MongoDB for Windows:

  • MongoDB for Windows Server 2008 R2 edition only runs on Windows Server 2008 R2, Windows 7 64-bit, and newer versions of Windows. This build takes advantage of recent enhancements to the Windows Platform and cannot operate on older versions of Windows.
  • MongoDB for Windows 64-bit runs on any 64-bit version of Windows newer than Windows XP, including Windows Server 2008 R2 and Windows 7 64-bit.
  • MongoDB for Windows 32-bit runs on any 32-bit version of Windows newer than Windows XP. 32-bit versions of MongoDB are only intended for older systems and for use in testing and development systems.

Changed in version 2.2: MongoDB does not support Windows XP. Please use a more recent version of Windows to use more recent releases of MongoDB.

Note

Always download the correct version of MongoDB for your Windows system. The 64-bit versions of MongoDB will not work with 32-bit Windows.

32-bit versions of MongoDB are suitable only for testing and evaluation purposes and only support databases smaller than 2GB.

You can find the architecture of your version of Windows platform using the following command in the Command Prompt

wmic os get osarchitecture 

In Windows Explorer, find the MongoDB download file, typically in the default Downloads directory. Extract the archive to C:\ by right clicking on the archive and selecting Extract All and browsing to C:\.

Note

The folder name will be either:

C:\mongodb-win32-i386-[version]

Or:

C:\mongodb-win32-x86_64-[version]

In both examples, replace [version] with the version of MongoDB downloaded.

Set up the Environment

Start the Command Prompt by selecting the Start Menu, then All Programs, then Accessories, then right click Command Prompt, and select Run as Administrator from the popup menu. In the Command Prompt, issue the following commands:

cd \
move C:\mongodb-win32-* C:\mongodb

Note

MongoDB is self-contained and does not have any other system dependencies. You can run MongoDB from any folder you choose. You may install MongoDB in any directory (e.g. D:\test\mongodb)

MongoDB requires a data folder to store its files. The default location for the MongoDB data directory is C:\data\db. Create this folder using the Command Prompt. Issue the following command sequence:

md data md data\db 

Note

You may specify an alternate path for \data\db with the dbpath setting for mongod.exe, as in the following example:

C:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\data

If your path includes spaces, enclose the entire path in double quotations, for example:

C:\mongodb\bin\mongod.exe --dbpath "d:\test\mongo db data"

Start MongoDB

To start MongoDB, execute from the Command Prompt:

C:\mongodb\bin\mongod.exe

This will start the main MongoDB database process. The waiting for connections message in the console output indicates that the mongod.exe process is running successfully.

Note

Depending on the security level of your system, Windows will issue a Security Alert dialog box about blocking “some features” of C:\\mongodb\bin\mongod.exe from communicating on networks. All users should select Private Networks, such as my home or work network and click Allow access. For additional information on security and MongoDB, please read the Security and Authentication wiki page.

Warning

Do not allow mongod.exe to be accessible to public networks without running in “Secure Mode” (i.e. auth.) MongoDB is designed to be run in “trusted environments” and the database does not enable authentication or “Secure Mode” by default.

Connect to MongoDB using the mongo.exe shell. Open another Command Prompt and issue the following command:

C:\mongodb\bin\mongo.exe

Note

Executing the command start C:\mongodb\bin\mongo.exe will automatically start the mongo.exe shell in a separate Command Prompt window.

The mongo.exe shell will connect to mongod.exe running on the localhost interface and port 27017 by default. At the mongo.exe prompt, issue the following two commands to insert a record in the test collection of the default test database and then retrieve that record:

> db.test.save( { a: 1 } ) > db.test.find() 

See also

mongo” and “JavaScript Interface.” If you want to develop applications using .NET, see the C# Language Center wiki page for more information.

MongoDB as a Windows Service

New in version 2.0.

Setup MongoDB as a Windows Service, so that the database will start automatically following each reboot cycle.

Note

mongod.exe added support for running as a Windows service in version 2.0, and mongos.exe added support for running as a Windows Service in version 2.1.1.

Configure the System

You should specify two options when running MongoDB as a Windows Service: a path for the log output (i.e. logpath) and a configuration file.

  1. Create a specific directory for MongoDB log files:

    md C:\mongodb\log
  2. Create a configuration file for the logpath option for MongoDB in the Command Prompt by issuing this command:

    echo logpath=C:\mongodb\log\mongo.log > C:\mongodb\mongod.cfg

While these optional steps are optional, creating a specific location for log files and using the configuration file are good practice.

Note

Consider setting the logappend option. If you do not, mongod.exe will delete the contents of the existing log file when starting.

Changed in version 2.2: The default logpath and logappend behavior will change in the 2.2 release.

Install and Run the MongoDB Service

Run all of the following commands in Command Prompt with “Administrative Privileges:”

  1. To install the MongoDB service:

    C:\mongodb\bin\mongod.exe --config C:\mongodb\mongod.cfg --install

    Modify the path to the mongod.cfg file as needed. For the --install option to succeed, you must specify a logpath setting or the --logpath run-time option.

  2. To run the MongoDB service:

    net start MongoDB 

Note

If you wish to use an alternate path for your dbpath specify it in the config file (e.g. C:\mongodb\mongod.cfg) on that you specified in the --install operation. You may also specify --dbpath on the command line; however, always prefer the configuration file.

If the dbpath` directory does not exist, mongod.exe will not be able to start. The default value for dbpath is \data\db.

Stop or Remove the MongoDB Service

  • To stop the MongoDB service:

    net stop MongoDB 
  • To remove the MongoDB service:

    C:\mongodb\bin\mongod.exe --remove

89个答案

0

Powergenx is promising to sell supplements for body and health fitness. Different-2 name for exp Whey protein, Mass gainer 

Whey protein

0

Powergenx is promising to sell supplements for body and health fitness. Different-2 name for exp Whey protein, Mass gainer 

Whey protein

0

Powergenx is promising to sell supplements for body and health fitness. Different-2 name for exp Whey protein, Mass gainer 

Whey protein

0

I'm glad I found this web site, I couldn't find any knowledge on this matter prior to.Also operate a site and if you are ever interested in doing some visitor writing for me if possible feel free to let me know, im always look for people to check out my web site vehicle tax

0

Wow, What a Excellent post. I really found this to much informatics. It is what i was searching for.I would like to suggest you that please keep sharing such type of info.Thanks havuz kimyasalları

0

Thank you for a absolutely interesting blog. What else may additionally I profit that handy of data written in this kind of unadulterated right of get right of entry to? Ive a engagement that i am profitably now humming in the back of inspiration to, and i’ve been at the see out for such data. wild unknown tarot

0

That is very helpful for increasing my knowledge in this field. North Seeker

0

I realize this is one of the most meaningful counsel for me. And i am vivacious studying your article. however have to commentary upon some standard matters, the internet site style is unmodified; the articles are invincible. thank you for the ton of actual and viable explicit.  beyond 40 lean belly

0

You know your projects stand out of the herd. There is something special about them. It seems to me all of them are really brilliant! skin tags home treatment

0
待审核
0

This is an awesome motivating article.I am practically satisfied with your great work.You put truly extremely supportive data. Keep it up. Continue blogging. Hoping to perusing your next post matka

0

Thank a lot. You have done excellent job. I enjoyed your blog . Nice efforts satta

0

This is truly an practical and pleasant information for all. Thanks for sharing this to us and more power sattamatka

0

Nice blog, I will keep visiting this blog very often. free email account

0

Great post, please keep on sharing amazing article like this! It makes me happy reading your post satta

0

The software says exclusively relevant. Each of reduced attributes happen to be formulated with various capture certification. I like the application many. satta matka

0

I appreciated your work very thanks minecraftskindex.info

0

Hello, this weekend is good for me, since this time i am reading this enormous informative article here at my home. One Bernam Showflat

0

The first phase the preparation should, theoretically, be uninfluenced by the intended intensity and duration of the sound which is subsequently produced. In fact, however, so quickly are the three phases accomplished that the pianist rarely has capacity to think, in performance, of each phase separately. guessing forum

0

I really appreciate the kind of topics you post here. Thanks for sharing us a great information that is actually helpful. Good day! matka guessing

1 2 3 4 5