当前位置:网站首页>Mongodb learning notes (1) - install mongodb and its related configurations
Mongodb learning notes (1) - install mongodb and its related configurations
2022-07-27 19:09:00 【Xiao Li, who loves traveling】
MongoDB Learning notes (1)—— install MongoDB And its related configuration
List of articles
Step one : install MongoDB
1. Go directly to MongoDB Download it on the official website .
2. After downloading, click the installation package to install it as a fool .

Step two : Configure environment variables
1. First , find MongoDB Installation directory , Copy bin Catalog 
2. Create an environment variable : The value is the value just copied ( You can also create a MongoDB_HOME The way )
3. At this time, enter : mongo , Outputting the version number indicates that the configuration is successful .
4. stay c Root directory creation data Catalog 
5. stay data It creates db Catalog 
6. Command line window input : mongod
Turn on mongodb service , In the bottom line of the log, you can see that the default port is 27017
7. The command line window just now cannot be closed , Open a new command line window , Input mongo, You can connect to the service 
8. At this point, you can test several commands
> 1+1
2
> var a=10;
> var a = 10;
> a
10
>
9. Last , Can be in db File generation is found in the directory .
10.
Be careful :32 The first time the bit system starts the server , You need to enter the following command :
mongod --storageEngine=mmapv1
Step three : Customize MongoDB To configure ( Database file and port number )
1. Create in any directory mongo Catalog , Create below db and log Catalog 
2. Modify the location of database storage :
mongod --dbpath Pathname --port Port number
Enter at the command line :
mongod --dbpath D:\file\mongodb\db --port 10086
3. At this time, you can visit localhost:10086
mongodb I won't support it http Protocol connection , However, there is a prompt to prove that the service has been successfully started !
Step four : take mongodb Set as system service , Boot from boot
1. stay c Disk directory ( Other dishes are OK ) establish data Catalog , Create below db and log Catalog 
2. stay mongodb Create... In the installation directory mongod.cfg file 
3. write in
systemLog:
destination: file
path: c:\data\log\MongoDB.log
storage:
dbpath: c:\data\db
Command line input :
sc.exe create MongoDB binPath= ““D:\software\MongoDB\bin\mongod.exe” --service --config=“D:\software\MongoDB\mongod.cfg”” DisplayName= “MongoDB” start= "auto"
Note that the previous directory is installed bin In the catalog mongod.exe, The following is the full path of the configuration file
5. Open the service , find MongoDB service 
6. start-up MongoDB service
7. If an error will be reported, enter ;
sc delete MongoDB Delete the original service
8. Then the input :
mongod --dbpath=C:\data\db --logpath=C:\data\log\MongoDB.log --install --serviceName "MongoDB"
C:\Users\Administrator>sc delete MongoDB
[SC] DeleteService success
C:\Users\Administrator>mongod --dbpath=C:\data\db --logpath=C:\data\logs\MongoDB.log --install --serviceName "MongoDB"
2020-05-05T20:38:00.687+0800 F CONTROL [main] Failed global initialization: FileNotOpen: Failed to open "C:\data\logs\MongoDB.log"
C:\Users\Administrator>mongod --dbpath=C:\data\db --logpath=C:\data\log\MongoDB.log --install --serviceName "MongoDB"
2020-05-05T20:38:44.406+0800 I CONTROL [main] log file "C:\data\log\MongoDB.log" exists; moved to "C:\data\log\MongoDB.log.2020-05-05T12-38-44".
9. Start the service , Set the service to start automatically .
10. Enter at the command line : mongo
C:\Users\Administrator>mongo
MongoDB shell version: 3.2.4
connecting to: test
>
11. Observe log Under the table of contents , It is found that logs have been generated 
Be accomplished 
Level co., LTD. , For reference only , If there is any mistake , Hope to point out at any time !
边栏推荐
猜你喜欢
随机推荐
Led learning eye protection table lamp touch chip-dlt8t10s-jericho
Useful resources for ns2
Typescript installation
C interface knowledge collection suggestions collection
Performance analysis of continuous time systems (2) - second order system performance improvement methods PID, PR
There is a problem with the time zone when the idea connects to the database. The server returns invalid timezone is red Need to set ‘serverTimezone‘ property.
Unity学习笔记(刚体-物理-碰撞器-触发器)
Latex使用--subfigure竖排图形
JMeter interface automation - how to solve the content type conflict of request headers
Learning notes of Microcomputer Principles - common addressing methods
又有一个Repeater的例子
一篇让你掌握线程和线程池,还解决了线程安全问题,确定不看看?
Unity learning notes (rigid body physics collider trigger)
Word 2007+ tips
Unity display Kinect depth data
MySQL 03 advanced query (I)
Collection of software design suggestions of "high cohesion and low coupling"
WPS turns off annoying advertisements
Interceptor interceptor
Unity学习笔记——物体移动六种常见函数









