Install MongoDB on the window platform


One, MongoDB download

     Official website download address:  Click to open the link     to download the corresponding installation file according to whether your system is 32 or 64. (Note: MongoDB 2.2 version no longer supports windows xp system) 
   


Second, install MongoDB

 
  
  Double-click the file and follow the instructions to install it. During the installation process, you can set your installation directory by clicking the "Custom" button. 
  The installation directory on my computer is: D:\Program Files\MongoDB\Server\3.2\bin 

    Create a new data folder in D:\Program Files\MongoDB, and then create a new db and dbconfig folder under data. The db folder is used to store database files. Then create a new mongodb.log file under dbconfig.

    As shown in the figure: 
    

    
     
      

    

Three, configure MongoDB

    Open the cmd command line,
   cd D:\Program Files\MongoDB\Server\3.2\bin
   d:
   
    
    Execute again:
    mongod.exe --dbpath d:\Program Files\MongoDB\data\db
    
   Then set the binding IP, port, windows service: the service name is: hwj_mongodb
mongod.exe --bind_ip 127.0.0.1 --logpath "d:\Program Files\MongoDB\data\dbconfig\mongodb.log" --logappend --dbpath "d:\Program Files\MongoDB\data\db" --port 27017 --serviceName "hwj_mongodb" --serviceDisplayName "hwj_mongodb" --install 

  If you need to create a user and password, you also need to execute the following command:
  mongod.exe --auth --logpath "d:\Program Files\MongoDB\data\dbconfig\mongodb.log" --logappend --dbpath "d:\Program Files\MongoDB\data\db" --directoryperdb --reinstall
 
 Start the MongoDB service
 1. You can go to Computer-->Management-->Services to find hwj_mongodb and start it.
  2. Execute net start hwj_mongodb directly, and stop the service as: net stop hwj_mongodb

 The setup is complete here.

Four, mongodb basic commands

  运行: D:\Program Files\MongoDB\Server\3.2\bin\mongo.exe

  As shown in the figure: 

  

    

  View all databases:

  show dbs;

  New database:

  use mongo_demo;

  db.runoob.insert({"name":"www.junlenet.com"})

  show dbs;

   

  More commands can be accessed:  Click to open the link

   

Guess you like

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