MongoDB database installation notes

1, the database (Database)

按照数据结构来组织、存储和管理数据的仓库。

2, the database classification:

  • Relational database (the RDBMS)
    · MySQL, the Oracle, the DB2, SQL Server ...
    · full table
  • Non-relational databases (SQL No)
    · MongoDB, Redis ...
    · key-value database
    -document database MongoDB

3、MOngoDB

  • Minimalist, flexible, as part of the Web application stack, MongoDB is a document-oriented data model, is a structure similar to JSON. (BSON)
  • 下载MongoDB:https://www.mongodb.org/dl/win32/

4, install MongoDB

  • 1, the installation
  • 2, configure the environment variables
    • Path (to bin) MongoDB added to the installation environment variable (path)
  • 3. Verify that the installation was successful
    • Open the CMD, enter mongod
  • 4, in the root directory of C
    • Create a folder data
    • Create a data file in the folder db (default directory MongoDB database)
  • 5, open CMD command window
    • Enter mongod start MongoDB server
    • Note: 32-bit system when you first start the MongoDB database, the command is: mongod --storageEngine = mmapv1
  • 6, and then open a CMD window
    • Input connection mongo MongoDB, show: connecting to: test indicates a successful connection MongoDB database. Appears>
  • 7, starts MongoDB database and set the database path (this database may be set to any position of the path, instead of the default data db in the C drive)
    • Open the CMD, enter the command: mongod --dbpath path
  • 8, start the MongoDB database, the default port is 27017, can be modified through the command port
    • Open the CMD, enter the command: mongod --port port number
    • Would set a good database path port number: mongod --dbpath path --port port number
    • Best to use the default port number, not more than 1,000 minimum, maximum not more than 65,535
  • 9, database (database)
    • Server database
      • Server used to store data
      • mongod used to start the server
    • Client database
      • Client to a server operation, the data CRUD operations.
      • mongo used to start the client
  • 10, MongoDB will be set as a system service, you can start automatically in the background, you do not need to manually start each time.
    • (1) create data in the root directory of C (not necessarily the path to the database in the C drive, as already explained)
      • Creating folders db and log in data
    • (2) create a configuration file
      • Adding a configuration file in the installation directory (the same bin at the same level) mongod.cfg
      • Within mongod.cfg file path is subject to its own path
      • mongod.cfg configuration file as follows:
systemLog:  		 
	Destination: file 
	Path: c:\data\log\mongod.log 
storage: 
	dbPath: c:\data\db
  • (3) Open a command window as an administrator
    Here Insert Picture Description

  • (4) Run the following command (whichever path has its own installation path):

sc.exe create MongoDB binPath="\"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe\" --service --config=\"C:\Program Files\MongoDB\Server\3.4\mongod.cfg\"" DisplayName= "MongoDB" start= "auto"
  • (5) start the MongoDB service
    • Right-open the Task Manager, click on "Services" all services open to view, find MongoDB, right-click "start"
  • (6) If the startup fails to prove that on top of a mistake
    • In the console enter service configuration before you remove the sc delete MongoDB
    • And then again from the first step
Published 76 original articles · won praise 26 · views 70000 +

Guess you like

Origin blog.csdn.net/qq_29326717/article/details/103936081