Windows Platform Installation MongoDB

Source: Internet
Author: User
Tags mongodb server

1. Download MongoDB software

Official website: https://www.mongodb.com/download-center#community

Choose an installation package for Windows

It is important to note that only 64-bit servers are currently supported, and the size is around 150Mb

Can be downloaded by the browser, or download tools can be downloaded, generally speaking foreign websites download software with the speed of downloading tools faster,

After downloading, double-click the file and follow the instructions to install it.

During the installation process, you can set up your installation directory by tapping the custom button.

2. Create a Data Catalog

MongoDB stores the data directory in the DB directory. However, this data directory is not actively created, and we need to create it after the installation is complete. Note that the data directory should be placed under the root directory (e.g. C: \ or D:\. , etc.).

In this tutorial, we have MongoDB installed on C Drive, now let's create a directory of data and create a DB directory in the data directory.

We can use the cmd command line to create a data\db folder under the C packing directory
C:\>cd C:C:\>mkdir datac:\>cd datac:\data>mkdir DBC :\data>cd DBC:\data\db>

You can also create these directories through the Windows Explorer, not necessarily through the command line.

the 3.MongoDB server command prompt runs:

Here, MongoDB has two main parts: Mongod.exe and Mongo.exe, the former server, the latter for the operation of the background. To successfully run MongoDB, you first build and run the server, and then open the background while keeping the server running.

A.Since the pre-installation does not generate the data directory, I need to create it myself, my data directory is C:\data\db B.Run cmd, open the bin file in your own installation directory, and execute the Mongod.exe file in the bin directory. Enter as follows:

CD C:\Program Files\mongodb\server\3.4\bin
Mongod.exe–dbpath c:\data\db


If the execution succeeds, the information is output as above.

c.The first two steps set up the server, the previous CMD window is maintained, and a CMD window is opened to run Mongo.exe.

Also open the bin file, execute Mongo.exe, you can go into the MongoDB shell interface to operate.

The 4.MongoDB server runs as a Windows Server:

The previous three steps have been fully installed and can run MongoDB, but when Mongod.exe is closed, Mongo.exe cannot connect to the database, so every time using MongoDB to open the Mongod.exe program, very troublesome. Installing the MongoDB server as a Windows service resolves this issue.

A.Create a new two directory yourself: Data directory C:\data\db and log directory C:\data\log b. Run cmd, must be run as Administrator!!!

Enter the following:

CD C:\Program Files\mongodb\server\3.4\bin
Mongod.exe–logpath "C:\data\log\mongodb.log" –logappend–dbpath "C:\data\db" –servicename "MongoDB" –install
net start MongoDB

PS: net start MongoDB for Start MongoDB service, net stop MongoDB stop MongoDB service.

At this point you can observe the changes in two positions:

    • 1.c:\data\log The Mongodb.log file appears, open to see the following:



In the log, we set up the operation record of the server, and have already run, the default port 27017 waits for the connection.

    • 2. Open Task Manager, the process will appear in the MongoDB server, so you can also use the Task Manager to close the MongoDB server

c.Run Mongo.exe

Also open the bin file, execute Mongo.exe, you can enter the shell interface
As shown in the following:

In this way, MongoDB installs and describes the MongoDB server as the Windows service running steps, and there are some pits to emphasize.
1. When you run the MongoDB server as a Windows service, be sure to run as an administrator, or there will be an error due to no permissions.
2. If the server fails to start correctly during the operation, try to delete the Mongod.lock file in C:\data\db because the file will lock the server when the server exits the exception.

Windows Platform Installation MongoDB

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.