A brief introduction to MongoDB
MongoDB is a database based on distributed file storage. Written by the C + + language. Designed to provide scalable, high-performance data storage solutions for Web applications.
MongoDB is a product between a relational database and a non-relational database, and is the most versatile and most like relational database in a non-relational database.
MongoDB stores the data as a document. MongoDB is a database based on distributed file storage.
MongoDB is a kind of nosql. (NoSQL = not-only sql), meaning "not just sql." It is a non-relational database for ultra-large-scale data storage.
The pros and cons of NoSQL:
Advantages:
- -High Scalability
- -Distributed computing
- -Low cost
- -Architecture flexibility, semi-structured data
- -No complicated relationship.
Disadvantages:
- -No standardization
- -Limited query function (so far)
- -final agreement is not intuitive program
So what are the characteristics of MongoDB, official description ~
- MongoDB provides a document-oriented storage that is simple and easy to operate.
- You can set the index of any property in the MongoDB record (for example: Firstname= "Sameer", address= "8 Gandhi Road") for faster sorting.
- You can create data mirroring either locally or on the network, which makes MongoDB more extensible.
- If the load increases (requiring more storage space and greater processing power), it can be distributed across other nodes in the computer network which is called a shard.
- The MONGO supports rich query expressions. Query directives use a JSON-style tag to easily query objects and arrays embedded in the document.
- MongoDb uses the update () command to implement a replacement of the completed document (data) or some specified data fields.
- The map/reduce in MongoDB is primarily used for batch processing and aggregation of data.
- Map and reduce. The map function calls emit (Key,value) to traverse all records in the collection, passing key and value to the reduce function for processing.
- The map function and the reduce function are written in JavaScript and can be executed with the Db.runcommand or MapReduce command.
- Gridfs is a built-in feature in MongoDB that can be used to store a large number of small files.
- MongoDB allows you to execute scripts on the server, write a function in JavaScript, execute directly on the server, or store the definition of the function on the server, next time you call it directly.
- MongoDB supports a variety of programming languages: ruby,python,java,c++,php,c# and many more languages.
- MongoDB installation is simple.
MongoDB Installation
MongoDB installation is very simple, in fact there are two: the first is to download the compressed package file, unzip the use, the second is to download the MSI file, installation use.
(1) Download the official MSI file
I'm a 64-bit here.
After downloading the direct installation is OK, step by step according to its operation finally my path changes to E:\Program files\mongodb\server\3.0 in this folder below can be found
It's best to look at the readme provided by itself.
And then go to the bin file.
The two files are commonly used in the bin file.
Mongod.exe is used to start the MongoDB service (meaning that your database can be used after startup)
Mongo.exe is used to boot into the database (then you can command to manipulate the database meaning)
Tip with this MSI installation you need to be aware of:
1. The installation path is too long by default (because the execution of the rear mongo.exe you need to knock the command in.) You can pull it closer and take the bin out. Like my E:\mongoDb\bin.
2. Create a folder at the root of the disk and then create a folder in the database. DB is used to store the data. E:\data\db (do not do so, click Mongod.exe will frequently flash back ~)
Well, once created, you can click on Mongod.exe to open the service directly.
A long string (generally we can create a log file for it, so that the log will be recorded, of course, the console is basically no output) ... It is now listening to local port 27017 by default.
OK now the browser input address http://localhost:27017/can see the service has been successfully opened
Next try to manipulate the database: command line into the folder where the program
(Tip: If the service is not turned on, it may cause the following error)
Open Service (mongod.exe) After that, the general can be solved ~
Try it, and then you can use its syntax for database operations, help
(Tip: The cause of the error, if re-open the service is still not resolved, there are other ways)
1. See if the MongoDB service is turned on (or run services.msc to see if the service is turned on).
2. Look at the Data folder under the DB folder lock file There is no, if any, delete it, contact lock
3. Turn on the service.
In short, the error is that you did not open the service or open the service after the lock file is still locked something.
(2) If you are downloading a compressed package
Well that's good, just unzip it out, you need to create a path yourself, such as E:\Program Files\mongodb and then put the extracted Bin folder in
In the same vein, set up the Data folder E:\Program Files\mongodb\data under E:\Program files\mongodb, and then set up Db,log two folders on the bottom of data.
DB must, log random, but no log message can only output in the console, some confusion and will be lost
DB is used to give the database the default use of log to place the configuration file (and then create a log file under the log folder such as Mongodb.log)
Then configure it so that MongoDB knows which files to use
Console access to your Bin folder
> CD E:\Program files\mongodb\bin
> E:\Program files\mongodb\bin>mongod--dbpath "E:\Program files\mongodb\data\db"
Enter the command above to use the DB folder
To configure the log,
> E:\Program files\mongodb\bin>mongod--logpath "E:\Program files\mongodb\data\log\mongodb.log"
You can also use a faster command to open the MongoDB service, then set it up (assuming I want to have the service name MongoDB)
> E:\Program files\mongodb\bin>mongod--servicename "MongoDB"
In this way, we can simply use net start MongoDB to start the service or net stop MongoDB to shut down the service
For the way the MSI is installed, it doesn't seem to be possible to configure the service (I planted it)
The official offers are as follows:
Execute the following command to run the MongoDB server as a Windows service (requires Administrator privileges)
" C:\data\dbConf\mongodb.log " " C:\data\db " " Yourservicename " " Yourservicename " --install
Among them, the specific parameters are:
--bind_ip |
Bind service IP, if bind 127.0.0.1, can only native access, do not specify default local all IP |
--logpath |
Specify the MongoDB log file, note that the specified file is not a directory |
--logappend |
Write a log using an Append method |
--dbpath |
Specify the database path |
--port |
Specifying the service port number, default port 27017 |
--servicename |
Specify the service name |
--servicedisplaynam |
Specifies the service name that is executed when there are multiple MongoDB services. |
--install |
Specifies the installation as a Windows service. |
The specific installation method is this ~
--------------------------------------------------------------------------------------------------------------- -----------------------
Can directly operate the database directly inside the console, you can also use the graphical tools Mongovue seems more convenient to the official download
Open it after you've installed it.
Poor Ah ... Charges apply. I heard that under the 1.3 version of the registration can be used ... Click OK
Here's a little bit about how it's used
First click on the plus sign to create a new one, because you have nothing, step is this: 0 1 2 3 4
Here's a rookie mistake I've made ...
Bullish picture, generally every step must go straight, are similar, but pay attention to the second step.
Because we create new and many databases are new and nothing, so it is generally directly empty. If you are sure there is a corresponding username and password database, then fill in
Otherwise, there is the following error: No instances
Well, then, create a new one, and then test save for a little bit of connect.
Well, it's finally out, and now we're going to do it with this graphical interface.
Right click the collection to see all the data, there will be three formats for viewing, respectively, the tree table text
Then continue to operate Baidu Library there has been an article introduced very good, need to enter Baidu library to view
---first introduced here--
MongoDB Installation instructions and Mongovue use