(reprint) Detailed illustrations MongoDB download, installation, configuration and use

Source: Internet
Author: User
Tags auth mongodb download mongodb server win32 robomongo

Remember to run CMD in Administrator mode, or the service will fail to start

Reprint: http://blog.csdn.net/boby16/article/details/51221474

Detailed illustrations documenting the process of installing the MONGO database in Win7 64. The installed version is mongodb-win32-x86_64-2008plus-ssl-3.4.1-signed.

I downloaded the source file: mongodb-win32-x86_64-2008plus-ssl-3.4.1-signed
My system: Win 7 bit 8g memory
To facilitate the download, I put the package I downloaded at that time on a certain degree of cloud disk.
Link: http://pan.baidu.com/s/1o80MF1o Password: fi3k

Download and installation, a little more pictures, not afraid of wordy, afraid enough.

Pay attention to the location of this installation, and use it below.

The picture is said to have just installed the appearance of the time, hit a typo.

1. Create several folders as follows: Database path (data directory), log path (logs directory), and log file (Mongo.log file)

Note the front and back comparison of folders:

2. Create the configuration file mongo.conf, the file contents are as follows:

[HTML]View PlainCopy 
    1. #数据库路径   
    2. dbpath=D:\MONGO\DATA  
    3. #日志输出文件路径   
    4. logpath=D:\MONGO\LOGS\MONGO.LOG  
    5. #错误日志采用追加模式   
    6. logappend=TRUE  
    7. #启用日志文件,  &NBSP is enabled by default;
    8. journal=TRUE  
    9. # This option can filter out some useless log information, if you need to debug use set to FALSE  
    10. quiet= TRUE  
    11. #端口号   default to 27017  
    12. port=27017   


3. Start MongoDB Service

Mongod--config "D:\Mongo\mongo.conf"
This is to start the service using the configuration file that you have just configured above. Note Modify the directory location to your own. Well, of course this is the corresponding installation bin directory in the cmd command-line window dropdown

This is executed at the cmd command line, after execution, the command line does not seem to change much, and then you proceed to the following steps.

This step, in the fourth step below, you can see this step of the command execution effect. You can look at the next step diagram.
After the command executes, enter http://127.0.0.1:27017 in the browser to see the following interface that indicates the success of the launch

Some may fail here, perhaps the page does not show so, but it does not matter, you see just the data directory there is no file generation, there is no content log file. If there is, then the service is started,

You can also, in the Task Manager, see if there is such a MONGO service. All can be judged by this service start OK No.

4. Create and start the MongoDB service
It would be rather troublesome to create and start the MongoDB service by using the Windows service to manage the startup and shutdown of MongoDB if the operation is done on a per-action basis.

Mongod--config "D:\Mongo\mongo.conf"--install--servicename "MongoDB"
net start MongoDB

It's a 2-line command.

The start of this service is a bit special. No login verification is required, or you can log in without a password. Concrete look. This is the effect that you see with Mongovue login

Wait a minute, the description on the diagram is not very correct, it should be I created a database called LXKDB, the other 2 of the above is called admin, and Local is installed after MONGO DB, automatically generated database.

You can also see that there is no database called Test, so it is wrong to say that the system has a database called test by default. The following will also explain the problem.

This sentence was later updated: It said that this test does not exist, is not entirely right, specifically, the bottom of the explanation it. Don't care about this first.

Where Admin This database is stored user information.

About this user information, not as simple as we think, just save a username and password is finished.

MongoDB default is not set permissions, that is, no access permissions set.
This means that as long as the port of the MongoDB server is known, anyone who can access the server can query and manipulate the contents of the MongoDB database.
That is, as I tested above, do not enter anything, you can directly test connection OK.
So: add--auth so that you can use the user name and password later to do MONGODB related operations
MongoDB Users and permissions, this is a little complicated, first of all, an impression.
There are two kinds of database users, one is administrator, used to manage users, one is a normal user, to access data.

(I'll continue to talk about how the database users of both kinds of permissions are using it)

Attention:

Below this with permission to control the installation of services, you, temporarily do not complete, this permission if you open, you must first build an account and password in the database.

This is like the reason you have to have the key ready before you lock the lock. Therefore, in the case you do not understand this permission, temporarily do not add this permission control.

Wait until you see how to create a new administrative user and a general database user before you open this permission. I'll make a good summary of it later.

Explanation of--safety and certification:

The database in each MongoDB instance can have many users. If security checks are turned on, only database authenticated users can perform read or write operations.

In the context of authentication, MongoDB will treat the normal data as the admin database. Users in the Admin database are considered superuser (that is, administrators).

After authentication, administrators can read and write all databases and execute specific administrative commands, such as listdatabases and shutdown.

Be sure to have at least one administrator account before you start the security check.

Back Links: detailed schematic records Win7 MongoDB new manager account and general account examples

Then, the service to uninstall (the following explains how to uninstall the service, I do not repeat), and then re-register a service, command to add a--auth.

Mongod--config "D:\Mongo\mongo.conf"--auth--install--servicename "MongoDB"
net start MongoDB

You can also add a auth=true configuration to the configuration file. The effect is almost right.

Then you can't just log in without a password.

Note: This Mongovue version is too low, resulting in even if your account password OK, or there will be abnormal situation, after I have been a lot of unloading load service, changed a MONGO database Tools, special is OK.

Let's ignore the error of the tool for the time being. Next I demonstrate how to use this database, in this know this permission problem, just fine.

And this permission problem, is very troublesome.

The MONGO service that has just been installed has a default database, and Test,user's name and PWD are test. Such as.

Point test, testing, connection is not OK. And then there's the

Originally I was to read someone else's article said, MONGO just installed, there is a test database, and then the user name and password are test, and then I use that mongovue this visual tool to test the next.
The test connection was found to be OK, as shown above. Then I thought there was a real database, but then I thought, "No, it's not like that."
After I repeatedly test that permission problem, found that this mongovue, even if you do not fill in the user name and password, fill in the database name, and then test the connection, you can also test OK.

But I use another newly discovered MONGO database tool that doesn't have this problem.

And also use this MONGO database tool, you can see that--auth of the utility or exist, I this has not been tested, no permission to control the start-up service, and then use this login database to see what the situation.
Have time, or, crossing you to test the Bai. Just didn't add--auth when the service is started, is not without the account password, you can use this tool to connect to the database.

The URL of this tool is an open source project.

Robomongo 0.9.0
http://blog.robomongo.org/robomongo-0-9-0-final/
I downloaded to a certain degree of cloud disk share
Link: Http://pan.baidu.com/s/1bp8ALDP Password: Iaie

After comparing the two tools, you can see that the Mongovue version is really too low. The next article has this Mongovue version of the map.

If you need to uninstall the MongoDB service , it is still in the bin directory,
Mongod.exe--remove--servicename "MongoDB"

Then the service is deleted, and then you can't see the service in that Task Manager. It means he was killed. deleted.

In the future if you want to stop this service, you right-click, start the Task Manager, select the service above, then the bottom right corner of the "service (s) ...", and then find the system called MongoDB Service, turn it off.



At this point, all operations have been completed and the service has been successfully installed.
I will temporarily first put this MONGO database on my computer, how to use the specific. Say it later.

This time, look at just our new Data folder and Mongo.log two files in the time we found that there is information, it can also be explained that the operation is OK.

The amount, hehe, is I this picture upload a bit more ...

Finally, every time you want to use the MONGO command at the command line, you have to go into the corresponding bin directory, this is very troublesome, why not configure a system environment variable, convenient for direct use, this MONGO command

This can be directly on the cmd command line, do not need to do directory switching, you can directly use the

Explanation of the existence or not of the test database inside the database:

(reprint) Detailed illustrations MongoDB download, installation, configuration and use

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.