MongoDB Common operations

relational database nouns vs. MongoDB: relational database Mongodb Database Database Table Collection Row Document Index Index Join

MongoDB Replica set Environment construction

Environment Introduction:192.168.1.250 Main port=27408192.168.1.250 arbitration port=27409192.168.1.251 Preparation port=27408[Email protected] ~]# tar xvf mongodb-linux-x86_64-2.6.10.tgz[Email protected] ~]# mkdir-p/export/mongodb[Email protected] ~

One MongoDB statistic requirement

Demand:A colleague from the off-duty operation sent a requirement to count the number of occurrences of a field (_ID) in all document in a collection in the database. The range of the _id field is 0-4000.Suppose collection is like this:{ 123},{

MongoDB Environment Deployment

MongoDB Environment Deployment1. Environmental statementInstallation software: mongodb-linux-x86_64-2.2. 2 . tgz Software Installation location:/usr/local/mongodb datastorelocation:/var/mongodb/datalog storage location:/var/ Mongodb/logs2. Software

Linux (CentOS) mongodb Install

File down:http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.9.tgz/usr/local/Tar zxvf mongodb-linux-x86_64-2.4. 9 . TGZMV MongoDB-linux-x86_64-2.4. 9 mongodbcd mongodbmkdir dbmkdir logscd binvim

MongoDB Basic Command

MongoDB Basic Command >show DBS//Display a list of current data >DB//Display the current database object or collection >use ' DB name '//connect to a specified database Keep the database name: Admin:

MongoDB Learning Notes (iii)

Common directives1. Go to the heavyDb.runcommand ({distinct: ' person ', key: ' Home '});  2. GroupingDb.runcommand ({group:{ns: Collection name, key: Grouped key, initial: initialization, $reduce: decomposition, Condition: condition, Finalize:

MongoDB Broken Read

1. How to read data from a backup nodeDefault is not allowed, the following error will be reported:Testreplset:secondary> Show dbs- -19t10:03.196+0800 E QUERY "OK"0"errmsg" " Not master and Slaveok=false""code"13435If you want to allow the backup

MongoDB installation Configuration

MongoDB InstallationVim/etc/yum.repos.d/mongodb-org-3.0.repoJoin:[mongodb-org-3.0]Name=mongodb Repositorybaseurl=http://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.0/x86_64/gpgcheck=0enabled=1then install:Yum install-y

PHP Connection MongoDB

wget ' Https://codeload.github.com/mongodb/mongo-php-driver/zip/master '-o/usr/local/src/mong_php.zipcd/usr/local/src/Unzip Mong_php.zipCD

MongoDB (iii):: Small detail issues

1. Documentation{"Greeting": "Hello,world", "foo": 3} The key/value pairs in the document are ordered, and the following document is a completely different two document from the document above. {"Foo": 3, "greeting": "Hello,world"}2. Usage

MongoDB additions and deletions to search and change

MongoDB comes with a JavaScript Shell, so it is possible to use the JS syntax in it.Insert operation:Single Insertvar single={"name":"mei"," Age ":}db.user.insert (single);Loop insertvar single={"name":"tinyphp","num ":",} for(var i=0;i5; i++) {

The composition of the MongoDB replica set

1>, synchronization: Replication is used to back up data between multiple servers.The replication functionality of MongoDB is implemented using the log Oplog, the operations log contains each write operation of the master node.Oplog is a fixed

MongoDB Base Statement

MONGO additions and deletions to searchShow DBS shows all DBTo which db the use Fengdb is converted, without which a new db is created automaticallyDB Displays the current operation's DBDb.fengDb.insert ({"Name": "Fengnovo"}) adds a record to the

MongoDB Shard (sharding)

1. ConceptSharding (sharding) refers to the process of splitting data and dispersing it across different machines. This concept is sometimes represented by partitioning (partitioning). Spread the data across different machines without the need for

MongoDB common Operations--collection 1

1. Create a CollectionThere are two ways to display create and implicitly createDisplay creation can use command Db.createcollection ("collection name")Implicit creation can use the command DB. Collection name. Insert ({}), which refers to creating

Example of using group in mongodb

Next, I will talk about the group function of mongodb, which is quite powerful. It is quite complicated to use, such as find (), skip (), and distinct.Test data The code is as follows:Copy code > Db. fruit. find ();{"_ Id": 1, "category": "fruit"

Copy the database copyDatabase () from mongodb (). Release disk space.

Db. copyDatabase ("from", "to", "127.0.0.1: 16161 ");Replace the from library on 127.0.0.1. Copy to the to library.This has an additional benefit. That is, the from database may have deleted the data. We know that the disk space will not be released

MongoDB implements mysql primary key autoincrement

By default, a _ id field is used as the autoincrement auto-increment implementation. The _ id field type is objectid (objectid is a 12-byte BSON type ). ObjectId.Now, due to database migration, some of the central mysql locations tables in the

MongoDB array operations

$ Push: add an element to the document array. If this array is not available, the array is automatically added. The code is as follows:Copy code Db. users. insert ({"name": "zhang "})Db. users. update ({"name": "zhang" },{ "$ push": {"emails":

Total Pages: 409 1 .... 378 379 380 381 382 .... 409 Go to: GO

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.