1, from the official website (http://www.mongodb.org/downloads) Download MongoDB installation, I downloaded 3.0.4 64-bit version
2. After installation, create a new data directory and logs log directory in the installation directory, create a new mongod.log log file under Logs, and create a new mongod.cfg configuration file under the installation directory.
Mongod.cfg File Add content:
Logpath=d:\mongodb\logs\mongod.log #指定日志输出路径
Dbpath=d:\mongodb\data #指定数据目录
Logappend=true # log files automatically accumulate instead of overwriting
bind_ip=127.0.0.1 #绑定服务IP, if the binding 127.0.0.1, it can only be accessed natively, do not specify the default local all IP
port=27017 #指定服务器监听的端口, default is 27017
#auth =true #启用验证
3. Run the DOS window as Administrator and switch to the D:\mongodb\bin directory to execute the following command:
Mongod--dbpath D:\mongodb\data
After the command is executed, the window displays the following information, which starts successfully:
2015-07-22t09:15:40.508+0800 I NETWORK [Initandlisten] waiting for connections on port 27017
The following information is displayed in the browser input localhost:27017:
It looks like you is trying to access MongoDB over HTTP on the native driver port.
4. MongoDB is installed as a Windows service
Close the 3rd step of the DOS window, re-open the DOS window as administrator, and switch to the D:\mongodb\bin directory to execute the following command:
MongoDB--config D:\mongodb\mongod.cfg--install
After the installation is complete, you can view the MongoDB service to the Windows service, the default name is MongoDB
5. Add Super Admin user
Execute under the MongoDB client:
Use admin
db. Createuser ({user: " Siteuseradmin " pwd: " password " roles: [{ Role: "root" db: "admin" } ] } )
< span class= "s2" > < Span class= "p" > when added, you need to modify the Mongod.cfg file, remove the # number from the front of the #auth=true, and reload the configuration file with the following command:
Mongodb-f D:\mongodb\mongod.cfg
####################################
< span class= "s2" > < Span class= "p" > Check database without authentication error error
< span class= "s2" > < Span class= "p" > show DBS
< span class= "s2" > < Span class= "p" > "ErrMsg": "Not authorized the admin to execute command
< span class= "s2" > < Span class= "p" > After successful authentication will display 1
Db.auth (" siteuseradmin "," < span class= "s2" >password ")
Using show DBS again will not be an error.
MongoDB Windows environment Installation and configuration