Installation and configuration of MongoDB under windows

If it is free to install, skip steps 1 and 2.

1. Log in to Mongodb official website https://www.mongodb.com/download-center#community to  download the installation package. Both 32 and 64 bits will do.

2. Install MongoDB

Downloaded installation package:

The installation is relatively simple, similar to ordinary QQ software. The main thing in the middle is to select "Custom" to customize the installation path and modify it: D:\software\MongoDB

Then continue to "Next", the installation to the end.

 

Installation is easier. The difficulty lies in starting the Mongodb service and setting MongoDB as a Windows service. The configuration file can be found in the "Services" of Windows.

 

Third, first create the storage location of the database file

Create data under MongoDB, and then create db under data: D:\software\MongoDB\data\db

Because the storage folder of the database file must be created before starting the mongodb service, otherwise the command will not be created automatically, and the startup cannot be successful.

 

Fourth, start the MongoDB service

1. Open the cmd command line

2. Enter the D:\software\MongoDB\bin directory (note: first enter d: to enter the d drive, then enter cd D:\software\MongoDB\bin)

3. Enter the following command to start the mongodb service: mongod --dbpath D:\software\MongoDB\data\db

That is, it is started under the database storage file path created in the third step.

 

4. Enter http://localhost:27017 (27017 is the port number of mongodb) in the browser to view, if it displays:

It means that the connection is successful. If unsuccessful, you can check whether the port is occupied.

But in the local windows "service", the mongodb service is not configured, you can open the "service" to see

 

Five, configure the local windows mongodb service

In this way, it can be set to start automatically when it is turned on, and it can be started manually and shut down directly. It can be started through the command line net start MongoDB. This configuration will be greatly convenient.

1. First create a new folder log under the data file (used to store log files)

2. Create a new configuration file mongo.config in Mongodb


Probably many people do not create .config configuration files. So here is a simple method:

First create a mongo.txt file, then open it, click "Save As", change the file type at the bottom to "All Types", and change the file name to mongo.config.

This will create a config configuration file.

 

2. Open mongo.config with Notepad and enter:

 

dbpath=D:\software\MongoDB\data\db

logpath=D:\software\MongoDB\data\log\mongo.log

 

3. Open cmd as administrator:

There may be many people who will not open cmd as an administrator. This is also introduced:

Find the running file of cmd in the following path

Then right click and run as administrator. After opening it, I found that there are more "administrator" words at the top than ordinary ones.

 

4. Configure the windows service:

cmd first jumps to the D:\software\MongoDB\bin directory.

输入:mongod --config D:\software\Mongodb\mongo.config --install --serviceName "MongoDB"

That is, install the service according to the mongo.config configuration file just created, named MongoDB.

When done, check the local services again.

If successful, you will find that there are more "MongoDB" services in the local service.

And that's it. haha~~~

You can use: "Auto-start at boot, you can manually start and close, and the command line net start MongoDB starts".

After it is turned on, it can be connected normally. You can use IDE such as pycharm to connect,

 

pycharm connects to mongodb, you can use pycharm to configure the mongo plugin connection .

Introduce a blog post for you to learn to install:

http://blog.csdn.net/heshushun/article/details/77777752

Guess you like

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