windows deploy MongoDB

Open the MongoDb download page and download Community Server and Compass separately. Note that you can check to install Compass at the same time when installing Community Server, but it will be slow, so it is recommended to download and install the two separately.

 

After downloading, install MongoDb first

Select->Complete will be automatically installed on the C drive, select->Custom can customize the installation location and choose according to personal needs. In my case select ->Custom.

Tick ​​the Install MongoDB Compass installation will be very slow.


 

Create a new folder data under the C drive or D drive, here I select the D drive, create a new db folder under the data folder, and execute the command

C:\mongodb\bin\mongod --dbpath d:\data\db

Create a log folder under the data folder of the d drive to record logs


 

Create a mongoDB configuration file, mongod.cfg and save it in the d:\data path. The mongod.cfg configuration is as follows:

 

systemLog:
destination: file
path: D:\data\log\mongod.log
storage:
dbPath: D:\data\db
net:
bindIp: 0.0.0.0
port: 27017

Execute C : \mongodb\b in \mongod . exe -- config "d:\data\mongod.cfg" -- install as an administrator to enable the application configuration file and then execute 
net start MongoDB
to start the mongoDB service

Use db.createUser({user:"admin",pwd:"123456",roles:["root"]}) to create an administrator user 
Use db.auth("admin","123456") to authenticate the user

using mongo 192.168. 1.1:27017/admin -u admin -p 123456 login to mongo
 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324683801&siteId=291194637