One, download
1. Official website: http://www.mongodb.org/; the address for the download installer is: http://www.mongodb.org/downloads, select the Windows 32-bit 2.4.0 version.
2. Download the MongoDB for. NET Driver Development Kit, the official c#driver is located under the driver menu at address: https://github.com/mongodb/mongo-csharp-driver/downloads. It is also known that there is a Samus drive: Https://github.com/samus/mongodb-csharp
Two, installation
1. Extract the Mongodb-win32-i386-2.4.0.zip to the directory E:\mongodb-2.4.0, that is, put the bin directory under the folder.
2. Create the Data folder in E:\mongodb-2.4.0, and then create db,log two folders under that directory, E:\mongodb-2.4.0 three folders (bin,data,log) in the file directory.
3. Create a log file under the log folder Log.log, which is the full directory: E:\mongodb-2.4.0\log\log.log.
4. Program Start mode
Enter the bin directory, enter CMD in the directory, return to pop-up cmd window
[Plain]View Plaincopy
- Mongod-dbpath "E:\mongodb-2.4.0\data\db"
Execute this command to create a database file of MongoDB to the C:\Program files\mongodb\data\db directory.
Then you install MongoDB as a Windows service
[Plain]View Plaincopy
- Mongod--logpath "E:\mongodb-2.4.0\log\log.log"--logappend--dbpath "E:\mongodb-2.4.0\data\db"--directoryperdb-- Install
Test database operation opens in Bin directory Mongo.exe
>help (View related information)
>db.foo.insert ({test:100}) (Insert test,100 field value to Foo table, Foo table as default table)
>db.foo.find () (View foo table data)
The results are as follows:
You can see that 2 records were inserted. Set,test
Other commands can be found on the help command or official website.
Problems encountered in solving
--------------------------------------------
1. First of all, of course, download MongoDB
The official website of MongoDB is: http://www.mongodb.org/,
Latest version downloaded in: Http://www.mongodb.org/downloads. Please note that to download the appropriate installation package for your system, I have chosen: Windows 64-bit r2+.
The file name after download is: Mongodb-win32-x86_64-2008plus-ssl-3.0.1-signed.msi, click Install.
According to the official document: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/
Starting in version 2.2, MongoDB does isn't support Windows XP. Please use the more recent version of Windows to use the more recent releases of MongoDB.
The main idea: starting with version 2.2, MongoDB does not support Windows XP. Use the newer version of Windows to work with the latest version of MongoDB.
2. Where to create the database file
In the bin directory where you installed MongoDB, open cmd, enter: Mongod Enter to start the service. will see:
Hotfix KB2731284 or later update is not installed. And the words C:\data\db not found.
This involves two questions. Say the 2nd one first.
The MongoDB default database folder path is c:/data/db (note: Although it is the default, you need to create it yourself). However, you can also set the default path yourself, such as d:/test/data/db. You must create a storage folder for the database files before you start the MongoDB service, or you cannot start successfully. When using the system default folder path, the start service does not need to add the--dbpath parameter description. If this is not the default path, there are two types of startup service formats:
(1) The path of Mongod--dbpath storage. such as: Mongod--dbpath d:\test\data "NOTE: The path cannot contain spaces, otherwise use the 2nd type"
(2) Mongod--dbpath "stored path". such as Mongod--dbpath "D:\My text\data"
This is set as the default database folder path [The file created below is related to the 5th step]:
(1) Create: C:\data\db folder, and create C:\data\log\mongod.log file.
(2) Create: C:\mongodb\mongod.cfg file, enter the following text in the file:
Logpath= C:\data\log\mongod.log
Dbpath=c:\data\db
3. Enter the URL in the browser: http://localhost:27017/. If the service starts successfully, you will see the following paragraph:
It looks like you is trying to access MongoDB over HTTP on the native driver port.
4. Go back to Hotfix KB2731284 or later update is not installed this issue from an official document in another paragraph:
If you is running any edition of Windows Server R2 or Windows 7, please Installa hotfix to resolve a issue with MEM Ory mapped files on Windows.
If you are running any version of Windows Server R2 or Windows 7, install the hotfix to resolve a memory-mapped file problem in Windows.
You need to download the Fix405791 patch from: HTTPS://SUPPORT.MICROSOFT.COM/ZH-CN/HOTFIX/KBHOTFIX?KBNUM=2731284&KBLN=ZH-CN, fill in the email, Microsoft will send you a patch to download the path of the mail to you, the mail is: http://hotfixv4.microsoft.com/Windows%207/Windows%20Server2008%20R2%20SP1/sp2/Fix405791/ 7600/free/451413_intl_x64_zip.exe. After the download is finished, click Unzip to WINDOWS6.1-KB2731284-V3-X64.MSU file, click the file, will install the patch, the process needs to restart.
5. As you open the MongoDB service each time, you need to enter a section of cmd text. You can actually add it as a service to start. The procedure is as follows:
Open cmd and enter the following text "Note: The path needs to be consistent with itself, see 2nd step":
Sc.exe create MongoDB binpath= "\" C:\mongodb\bin\mongod.exe\ "--service--config=\" C:\mongodb\mongod.cfg\ "" Displayname= "MongoDB" start= "Auto"
If no accident, you will see: CreateService success. Open cmd, enter services.msc, find the MongoDB service, and if it can start successfully, prove the path is correct. If it fails to start, it indicates a path error and needs to be removed (the command is: SC delete MongoDB) and then added again.
The official documents are: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/
MONGODB installation and problem solving-excerpt from the network