Gridfs Introduction
MongoDB documents are stored in the Bson format and support binary data types when we save data in binary format directly to MongoDB documents. But when files are too large, such as pictures and videos, the length of each
For example, if you want to create a "myTest" database, run the use MyTest command, and then do something (such as db.createcollection (' user '), so you can create a database called "myTest."First, the database commonly used commands1. Help View
Traditional relational databases are generally composed of three levels of databases (database), tables (table), records (record), and MongoDB are made up of three levels (db), Collections (collection), document objects (documents). MongoDB for
1. Start and stop MongoDB:
Execute the mongod command to start the MongoDB server. Mongod has many configurable options, we can view all options through Mongod--help, here are just a few of the main options:
Copy Code code as follows:
Increase Arbiter
Add the profile mongod1,mongod2,mongod3 to the arbiter of Shard1,shard2,shard3 three set sets, respectively.
Copy Code code as follows:
Replset=shard1
Replset=shard2
Replset=shard3
Start the Mongod
Today to share with you the more interesting knowledge of MongoDB, mainly include: aggregation, cursors.
One: Aggregation
Common aggregation operations are the same as SQL Server: Count,distinct,group,mapreduce.
Count
Count is the simplest,
1, view the database
> db.stats ();
{
"db": "Test", //Current database
"collections": 3, //Current database How many table
"Objects": 4, //Current database All table how many data
" Avgobjsize ": Wuyi, //per
In MongoDB, the Db.collection.find () method is used to retrieve documents from the collection. The Db.collection.find () method returns a cursor that retrieves the document. The Db.collection.findOne () method also performs a read operation,
This article will describe my installation MongoDB expansion process, we can have a little reference
Installation Environment
Linux Environment: CentOS 6.5Apache Version: 2.4PHP Version: 5.4.3MongoDB version: 2.6.5
First, download mongo-php
asp.net MVC4 use MongoDB to create album management instance sharing
TIPS: 1.Image to Base64 save to MongoDB field2. The data model is a nested association
First define the model layer:
public class Photo:iequatable {[Required] public string
The example in this article describes how Python generates MongoDB Objectid based on time. Share to everyone for your reference. The specific analysis is as follows:
MongoDB _id for the Objectid type, Objectid contains timestamp information, so
This article describes the way PHP implements MongoDB customization to generate the self-increasing ID. Share to everyone for your reference. The specific analysis is as follows:
Copy Code code as follows:
First create an automatic
Copy Code code as follows:
This is the default connection to the local 27017 port, of course, you can also connect remote host such as 192.168.0.4:27017, if the port is 27017, the port can be omitted
$m = new Mongo ();
Select the comedy
Introduction of MongoDB
MongoDB (name from "Humongous") is an extensible, high-performance, open source, schema free, document-oriented database with the advantages of a document database, key values for storage and relational databases. Official
A complete example of building a MongoDB cluster (replica set + Shard) ...Prepare four machines, each bluejoe1,bluejoe2,bluejoe3, and BLUEJOE0The replica set and the Shard policy determine such as the following:
3 replica sets will be
MongoDB will present all user information in the collection System.users of the admin database, which mainly includes the user name, password, and database information. MongoDB does not enable authentication by default, as long as it can connect to
1. Set operation1.1. Create a collectionMongoDB creates a collection with the Db.createcollection (name, options) method.FormatDb.createcollection (name, options)Where name is the collection name, is a string, options is optional, is a document,
Learning to write MongoDB, using the Nodejs. Here I put the hole first record, later can slowly find. This article is also slowly, for the sake of brevity, all omit the handling of errors.Basic operations:1. Increase1 varMONGO = require (' MongoDB ')
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