MongoDB installation

1: Installation

Mongodb official website to download the 32bit package http://www.mongodb.org/downloads

 

The following files will appear after decompression

 

Established under mongodb folder, copy the bin folder to the directory, this is equivalent to mongodb related commands installed: the installation disc C.

 

In order to facilitate the start mongodb, will join mongod.exe path environment variable, Computer -> Properties -> Advanced System Settings -> Environment Variables, add the path to it in:

 

In this way the command line used anywhere mongod command.

2: establishing a data file and start

In a new disk D is then mongodb folder to put the data file and a data file in a folder mongodb, log folder, file in the build mongodb.log log folder

 

Start mongodb service: Open a command line, type the command

>mongod --dbpath "d://mongodb//data" --logpath "d://mongodb//log//mongodb.log" --logappend

The following occurs represents a successful start at port 27017.

 

Parsing: mongod --dbpath command is to create a storage location of the database files, you need to determine the location of the database files are stored when you start mongodb service, otherwise the system will not automatically create, start, will not succeed.

    --logpath represents the path of the log files are stored --logappend represented additional way to write log files

On the browser you will see this message:

 

27017 default port, the port may be modified by --port command, such as: mongod --port 9888 "d: \\ mongodb \\ data"

 3: Start as a service

Every time you start the service are required to enter the above command, for convenience, may be written in the database window startup mode services.

>mongod --logpath "d://mongodb//log//mongodb.log" --logappend --dbpath "d://mongodb//data" --directoryperdb --serviceName MongoDB --install

So that only at the command line, type net start MongoDB can start the service, but do not know why, so I set up in the "service", the can not find MongoDB?

Later renamed start cmd as an administrator, enter the command:

 

sc create mongodb binPath= "c:\mongodb\bin\mongod.exe --service --dbpath D:\mongodb\data --logpath=d:\mongodb\log\mongodb.log --logappend --directoryperdb"

 

Delete Services Directive: mongod.exe --remove --serviceName "MongoDB"

Note that administrators use to start the command line

Such a service which will have the MongoDB service

 

During the toss mongodb services found database service can not start, playing error box: "service did not respond or control functions", tried many other methods are no solution

The last execution sc delete mongodb forced to delete mongodb Service


-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

1. free to create their favorite path, C: \ lucas \ MongoDB 
2. In the C: decompression download \ lucas under \ mongodb zip file, then C: New data folder C \ lucas under \ mongodb: \ lucas \ mongodb \ the Data 
3. then were established db, log two folders, so far mongodb under the following folder 
C: \ lucas \ mongodb \ bin 
C: \ lucas \ mongodb \ the Data \ db 
C: \ lucas \ mongodb \ the Data \ log 
creates a log file in the log folder MongoDB.log, i.e. C: \ Lucas \ MongoDB \ Data \ log \ MongoDB.log 
4. command line installation

C:\lucas\mongodb\bin>mongod -dbpath "C:\lucas\mongodb\data\db"
  • 1

After the installation is complete, open http://127.0.0.1:27017/ 
see

It looks like you are trying to access  MongoDB over HTTP on the native driver port.
Description has been installed successfully.

5. Operation: 
(note d, that is to start the program) Double mongod.exe the bin 
after start proceeding, then the program runs mongo.exe (note no d), the following interface 
test database operations

>help  (查看相关信息)
>db.foo.insert({a:1}) (往foo表插入a,1字段值,foo表为默认表) >db.foo.find() (查看foo表数据)


Taken together two articles easier to understand

Guess you like

Origin www.cnblogs.com/liujianshe1990-/p/11803037.html