Mongodb download installation configuration

Time:2021-2-26

Windows 10 installing mongodb

: first, download the latest version of mongodb installation program from mongodb’s official website,https://www.mongodb.com/, scroll to try mongodb for free

Select the community server community version, and select the installed version of windows

Installation: try to download the latest version 3.6.1 from mongodb official website. You cannot enter the installation because you need to access compass internally- install.exe If it is a personal computer, I believe there is no problem

No way, can only use back to the original version 3.4.4, installation, there is no such problem

Select an installation location and a selected installation location (C: mongodb). After the installation, you can see that the installed files already exist in this directory

You can manually create two empty folders in C: mongodb

C:\mongodb\data\db

C:\mongodb\log

And create an empty mongo.log

Start the server: run the CMD command window as an administrator in win10, enter the C: mongodbin directory, run the command, that is, the server that has run mongodb. If it is normal, there should be a line of text indicating that the server has been started normally, but my computer does not. I don’t know why

cd c:\mongodb\bin

mongod --dbpath C:\mongodb\data\db --logpath=C:\mongodb\log\mongodb.log --logappend




Connection: use the CMD command window, enter the C: mongodbin directory, and run the command

mongo

Start mongodb as a Windows Service: the above startup server is only one-time. When the command window is closed, the server will be shut down. You can start mongodb as a Windows service. Once it is started, the mongodb service will be started

mongod --dbpath C:\mongodb\data\db --logpath=C:\mongodb\log\mongodb.log --logappend --install --serviceName "MongoDB"

Or open the browser and enter the addresshttp://localhost: 27017, orhttp://127.0.0.1:27017

When viewing system services, you can see that mongodb’s services are running

Start mongodb service with configuration file: create a file in C: / / mongodb / config mongodb.conf Adding a configuration file has the same effect as running the command directly

Copy code

Dbpath = C: mongodb, data, DB, database file
logpath=C:\mongodb\log\ mongodb.log     #Log file
Logappend = true # the log adopts the append mode. After configuration, the mongodb log will be appended to the existing log file, and a new file will not be created
Journal = true # enable log file, which is enabled by default
Quiet = true # this option can filter out some useless log information. If you need to debug, please set it to false
Port = 27017? The default port number is 27017

Copy code
Then run the command

sc create MongoDB binPath= "C:\mongodb\bin\mongod.exe --service --config=C:\mongodb\config\mongodb.conf"






Delete mongodb’s windows service: if you no longer need mongodb’s windows service, you can delete it manually

You can run the command in any directory

sc delete MongoDB

Or run the following command in mongodb’s bin directory

mongod --remove --serviceName "MongoDB"


Add mongodb to environment variables: at this time, you can use mongodb’s command-line tools only when you enter mongodb’s directory. If you cannot use mongodb’s command-line tools in other directories, you can add mongodb’s directory to environment variables, so that you can use mongodb’s command-line tools anywhere

Open the Windows settings window, input variables, and click “edit system environment variables”

After adding environment variables to the bin directory you installed, you can use mongodb command-line tools in any directory