Label:MongoDB Common Commands SummarySimple additions and deletions to check the dataSpecify the display or not display a field in the query resultsFor example, we want to find all the data in the lessons collection, but we do not want to include the slides field in the returned result, because slides is a large, base64 array of images that affects the reading of the query results.Then we can follow a parameter after the query object. As follows: Db.l
Tags: string new manual OPD update var boolean journal baseMongodb:nosql Database
Important indicator points in MongoDB
The three elements in MongoDB
Database
Collection
Document
The data store in MongoDB is stored in the form of Bson, and Bson is a binary json, so it looks like the recorded form
remote database: E:\mongodb\bin>mongo ip:27017/db-u root-p Root
Some commands:
Show DBS (or use Show databases to view the current database situation, by default, test)
Use test if test does not exist create test database, show DBS cannot see, need to insert data
Db.test.insert ({"AA": "11"})
DB view which database is currently connected (Db.test2.insert () creates test2 data ta
",
pwd: "Password",
roles: ["ReadWrite", " DbAdmin "]
}
)
After installing the user in centos6.5 above the connection error, check the log mongodb.log:
AUTHENTICATIONFAILED:MONGODB-CR credentials missing in the user document
Very feeling the answer of this elder brother Vivek (Http://stackoverflow.com/users/2512718/vivek):
Http://stackoverflow.com/questions/29006887/mongodb-cr-authentication-failed
Go to
Label:http://blog.csdn.net/czw698/article/details/8791153 MongoDB provides several commands for shutting down the service, specifically the following: One use crtl+c off
[Email protected] data]$ Mongod--dbpath=/database/mongodb/data/--logpath=/var/applog/mongo_log/mongo.log-- Logappend--port=27017--journal > Start_mongo.log 2>1Cursor: type crt
Tags: System Mon Interface Course Line Code window Tom Insert PathToday to everyone apologized, did not update MongoDB Quick start of the next article, recently a little busy, here to the Bo friends apologize. Below I will briefly describe some of the basic commands of mongdb and some of the problems in our daily development process. MongoDB can provide us with a
(key,emits) {total=0;for (var i in emits) {Total+=emits[i].count;}return {"Count": total};}Mr=db.runcommand ({"MapReduce": "Tbname", "map": Map, "Reduce": reduce})Db[mr.result].find () Db.listcommands () Fixed collection, you can use a trailing cursor in your program to get the newly added documentDb.createcollection ("collection", {capped:true,size:10000,max:100})//Create fixed set, big trifle 10000 bytesDb.createcollection ("Mycappedcoll", {capped:true,size:10000,max:100,autoindexid:false})Db
Label:How to view commands: 1. Run Db.listcommands () in the shell 2. Accessing the administrator interface in the browser: http://ipaddress:28017/_commands The following are the most frequently used commands in MongoDB, as follows: Command: Buildinfo Format: {"Buildinfo": 1} Description: Manages a dedicated command that returns the version number of the
MongoDB Basic concepts and common commandsMongo DB is currently in ITa non-relational database (NOSQL) that is popular in the industry, and its flexible data storage methods are favored by current it practitioners. Mongo DB is a good implementation of object-oriented thinking (Oo idea), in Mongo db each record is a document object. The biggest advantage of Mongo DB is that all data persistence requires no developers to write SQL statements manually,
command" is a special type of query, because when the MongoDB server receives a command sent by a runcommand, it processes the request into a query operation of the $cmd collection. For example, Shel sends a db.runcommand ("Drop", "test") command (deleting a test collection) and the server is converted to DB. $cmd. FindOne ({"Drop": "Test"})When some commands need to have administrator rights, and in the a
# from a dbpath enabled from the Library Replication service, the DBPath database is a snapshot of the main library and can be used to quickly enable synchronization
--autoresync
# If synchronizing data from the library to the main library is much worse, automatic resynchronization
--oplogsize Arg
# Set the size of the Oplog (MB)
* Master/slave parameters
--master
# Main Library Mode
--slave
# from
1, MongoDB official website download: https://www.mongodb.org/downloads can download the installation version and press release; temporarily select Unzip installation 2, cmd into the MongoDB installation directory under the bin, start MongoDB. Mongod Open the command while using--dbpath to specify the data storage location as "DB" folder. Mongod--dbpath=e:\study\
conditions:MongoDB provides a set of comparison operators: $lt/$lte/$GT/$gte/$ne, which in turn is equivalent to --The following example returns a document that meets the conditions of age >= age > Db.test.find ({"Age": {"$gte": "$lte": 40}}){"_id": ObjectId ("4fd58ecbb9ac507e96276f1a"), "name": "Stephen", "Age": +, "Genda": "Male", "email": "[email protected]" }--The following example returns a condition that matches the name! = "Stephen1"> Db.test.find ({"name": {"$ne": "Stephen1"}}){"_id":
outDb.killop (Opid)Create a Collection1, create a collection that is 100 000 bytesDb.createcollection ("mycollection", {capped:true,size:100000})2, create a collection with a size of 100000 bytes and a maximum document count of 100Db.createcollection ("mycollection", {capped:true,size:100000max:100})Force buffer data to be flushed to diskDb.runcommand ({"Fsync": 1, "Lock": 1})Online Backup and Recoverymongodump-d Database-o Backupdirmongorestore-d Database--drop BackupdirMONGO MasterMasterMongo
}, "OK":1}>db.posts.stats () {"OK":0,"errmsg":"Collection [nutch.posts] not found." }>
Delete the currently used database: >db.dropdatabase ();
View the database currently in use: >db.getname (); >db;
The DB and GetName methods are the same effect and can query the currently used database
Current DB version: Db.version ();
Error message before query: Db.getpreverror ();
Clear Error Logging: Db.reseterror ();
User-related1. Add a userDb.addus
space size db.userInfo.dataSize ();4. Get the DB Db.userInfo.getDB () where the current aggregation set resides;5, get the current gathering state db.userInfo.stats ();6, get the aggregate aggregate size db.userInfo.totalSize ();7, aggregate storage space size db.userInfo.storageSize ();8. Shard Version Information Db.userInfo.getShardVersion ()9, Aggregation set rename Db.userInfo.renameCollection ("Users"); Rename UserInfo to users10. Delete the current aggregation set Db.userInfo.drop ();[SQ
collection 1, create a clustered collection (table) db.createcollection ("Collname", {size:20, capped:5, Max: 100}); 2, the Aggregation set (table) db.getcollection ("account") that gets the specified name, 3, gets all the aggregation sets of the current DB db.getcollectionnames (); 4, Displays the status of all clustered indexes in the current DB db.printcollectionstats (); user-related 1, adding a user db.adduser ("name"); Db.adduser ("UserName", "pwd123", true); Add users, set passwords, rea
The following format is MongoDB command | MySQL command, the latter as a referenceView DatabaseShow DBS | show databases;View Current Databasedb | Select Database ();Create a databaseUse Test1 | Create DATABASE Test1Note that it is not possible to show DBS in this time. An empty database needs to add at least one file Db.movie.insert ({"Test": "Test"})Switch databaseUse Test1 | Use Test1Deleting a databaseEnter Database Db.dropdatabase | Drop Database
Tags: color cat port Store field conf Information Tor DMI
Query based on the length of a field (title) in the collectionDb.collections. Find true " This.title.length " })// Note that kanji is not a character
Refresh the config information for the MONGOs cacheDb.admincommand ({"flushrouterconfig":1})// Refresh the cache after modifying configuration in config
Using pipelines to import a database from one instance node to another instance20001 passwd 20002 passwd -D dstdbname--archive
S
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.