to the database you want to create:
1
> use testdb;
To create a user:
1234567
db.createUser({user: "testUser",pwd: "testPass",roles: [ { role: "readWrite", db: "testdb"}] })
Sign in with your new account:
1
> db.auth("testUser","testPass")
Creates a new collection in the current database;
1
> db.table1.save({"id":"1"})
Displays the collection of the current database:
Show DBS View all databasesShow Tables View all collectionsdb Displays the current databaseuse+name switches to the specified database and creates a new if it does not existA document is a set of key-value (Key-value) pairs (that is, Bson). MongoDB documents do not need to set the same fields, and the same fields do not require the same data type{"Name": 2, "Age": 169}{"Name": "Óin", "Age": 167}{"Bianhao": +, "age": 82}Create a fixed-size collection d
})---------------------------------------------------------------------------------The number of cursor jump queries and qualified returnsDb.department.find (). Skip (10)Select top Ten *from department;Db.department.find (). Limit (10)---------------------------------------------------------------------------------The value returns the specified field, the first map writes the filter condition, the second map writes the returned field, and the default returns _ID, if it is not necessary to set t
: "3100000"}, {hostid: "3200000"}, "TAG1") Due to the current primary bit shard0003,Sh.addtagrange ("Mydb.location", {hostid: "3200000"}, {hostid: "3300000"}, "TAG2")Sh.addtagrange ("Mydb.location", {hostid: "3300000"}, {hostid: "3500000"}, "TAG3")Sh.addtagrange ("Mydb.location", {hostid: "3500000"}, {$maxKey: 1}, "TAG3") 4. Add ChunckPut the primary on the second shardDb.runcommand ({moveprimary: "MyDB", To: "shard0001"})View Shard ConditionDb.chunks.find ({ns: "Mydb.location"}) Manually establ
Take the maximum value of the Time field: Db.getcollection (' Calllog '). Find (). Sort ({"Time": -1}). Limit (1) Minimum value only need to change –1 to 1 Db.getcollection (' Calllog '). Find (). Sort ({"Time": 1}). Limit (1) Appcode field is not equal to "100001" record Db.getcollection (' Calllog '). Find ({"Appcode": {$ne: "100001"}}) Support Db.colls.find ({"field": {$gt: Value}});Db.colls.find ({"field": {$lt: Value}});Db.colls.find ({"field": {$gte: Value}});Db.colls.find ({"field": {$l
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
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
MongoDB is written in C + +, whose name comes from the middle part of the word HuMongous, from the name of which its ambition is the processing of massive amounts of data. One of the most concise descriptions of it is: scalable, high-performance, open source, Schema-free, document-oriented database. The main goal of MongoDB is to set up a bridge between key/value storage (which provides high performance and
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":
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.