Installation, use and problems of mongoDB and their solutions

Installation, use and problems of mongoDB and their solutions

 1. Installation

Download the installation package from the official website of mongodb http://www.mongodb.org/downloads . (Choose the installation package suitable for your computer system version)



 

2. Unzip

Unzip the downloaded installation package to a suitable folder.

3. Configure environment variables

Add the bin directory, Computer->Properties->Advanced System Settings->Environment Variables, to the path: D:\Program Files\Software\MongoDB\bin, so that the mongod command can be used anywhere on the command line. [Note: The bin directory is the related commands of mongodb.

4. Create a data file and start

Then create a mongodb folder to put data files and create data and log folders under the mongodb folder.

5. Start the mongodb service:

Open the command line and enter the command

>mongod --dbpath "d://mongodb//data" --logpath "d://mongodb//log//mongodb.log" --logappend Location. When starting the mongodb service, you need to determine the location where the database file is stored, otherwise the system will not automatically create it, and the startup will be unsuccessful. --logpath indicates the path where the log file is stored --logappend indicates that the log file is written by appending] If the startup is successful, the following interface will appear, and the browser input: http://localhost:27017/



 

6. Run the MongoDB server as a Windows service

Each time you start the service, you need to enter the above command. For convenience, you can write the startup database as a window service.

>mongod --logpath "d://mongodb//log//mongodb.log" --logappend --dbpath "d://mongodb//data" --directoryperdb --serviceName MongoDB --install

In this way, you only need to enter net start MongoDB on the command line to start the service. If it starts correctly, the following interface will appear



 

If the service cannot be installed successfully, start cmd as an administrator and enter the command:

sc create mongodb binPath= "c:\mongodb\bin\mongod.exe --service --dbpath D:\mongodb\data --logpath=d:\mongodb\log\mongodb.log --logappend --directoryperdb"

Remove service instruction:  mongod.exe --remove --serviceName "MongoDB"

Note that you need to start the command line in administrator mode, so that there is a MongoDB service in the service. As shown in the figure:


 

7. Install the graphical management tool Robomongo 0.9.0-RC9

 Link: http://pan.baidu.com/s/1c26wVtu Password: ak1p

8. Problems encountered

Windows cannot start MongoDB on local computer, error code 100

Solution: MongoDB installation directory \data\ delete mongod.lock and storage.bson in this folder

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326750981&siteId=291194637