MongoDB Common Commands Summary
simple 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 p
Label:Here, I simply record the basic commands MongoDB uses in the shell client, such as creating/displaying a database, creating a collection, deleting a collection, and so on.
First, start MongoDB and connect to the shell client Use the Mongod.exe and Mongo.exe commands to start and connect to the database s
MongoDB Basic Commands
After the MongoDB is successfully started, you can then open a command line window to enter MONGO to perform some operations on the database.
Enter help to see basic operations commands:
Show DBS: Displaying a list of databasesShow Collections: Displays the collection in the current database (si
How we want to delete a collection can take the db.test.drop () Way, in fact, behind this, this function is running the drop command. The same effect can be achieved with RunCommand. Let's start by creating a new collection to use as a test:> Use Maple1Switched to DB Maple1> Db.maple1.insert ({' name ': ' Zhanghongfeng '})Writeresult ({"ninserted": 1})Delete this collection, the results of the feedback ok:1 represents the Success> Db.runcommand ({"Drop": "Maple1"}){"ns": "Maple1.maple1", "Nind
: 28017/web admin port: 280172. Basic commands for getting started with mongodb show dbs: display the Database List show collections: display the set in the current database (similar to the tables in the relational database) show users: display the user db. help (): displays database operation commands. There are many command
Mongodb provides easy-to-use export and import commands.
1. Introduction and use of export commands.
MongoDB provides a simple export tool, which is located in {MongoDB_HOME}/bin/mongoexport.exe, for example (My mongodb is deployed in a windows operating system and is simila
collection does not exist) and the datadb. Collection name. Drop () Delete collectiondb.getcollection ("collection name") gets the information for a collectiondb.getcollectionnames () gets all the collections under the current databasedb.printcollectionstats () gets the state of all the collections under the current database
crud of DataInsert: db. Collection name. Insert ({"name": "Test", "Age":), note that only one of the JSON arrays inserted, "{}", of course, can contain sub-data, but
of values, or a data or a pair of key-value pairsExample: Db.mytest.insert ({age:1,name: ' name1 ', map:[2,2]})Db.mytest.insert ({age:2,name: ' name2 ', map:[2,3]})....Db.mytest.insert ({age:5,name: ' Name5 ', map:[5,6]})Add more than one piece of dataTo create a geospatial index:Example: Db.mytest.ensureIndex ({"Map": "2d"})7. Geo-Spatial index query: use $nearFind two closest points from [5,5]: Example: Db.mytest.find ({map:{"$near": [5,5]}}). Limit (2)8. Follow the graph to find: square {"$w
of the collectionDb.drop.Database (); Deleting a databaseDb.help () See Help informationvar x=db.user.find ();X.next ();X.next (); A one-way cursor in a recordX.hasnext ();Db.collection.update (Criteria,objnew,upsert,multi)Criteria: The object used to set the query criteriaObjnew object for setting updated contentUpsert: If the record already exists, update it, otherwise add a record, the value is 0 or 1 1 already exists update 0 newMulti: If there are multiple records that match the criteria,
Tags: mongodbThree ways to build a http://blog.csdn.net/luonanqin/article/details/8497860 MongoDB clusterNoSQL = Not the only SQL MongoDB storage method is document-type storage, not key-value form.MongoDB three ways to build a cluster: Replica set/sharding/master-slaverReplica set replica set cluster principle: (The simplest way to cluster)Master node, standby node, quorum node. The primary and standby nod
[Sorting] Summary of common MongoDB commands
Summary of common MongoDB commands
Simple addition, deletion, modification, and query dataSpecify whether to display or not to display a field in the query result.
For example, we want to search for all the data in the lessons collection, but do not want to include th
");
Comparison between mongodb and mysql commands
Traditional relational databases are generally composed of three levels: database, table, and record. MongoDB is composed of databases and collections) and document objects. MongoDB has no concept of columns, rows, and links for tables in relational databases, which
// 启动服务> net start MongoDBState Monitoring Static statisticsDb.stats ()// 查看单个数据库状态> db.stats()statsRelatively simple, you can refer to the db.stats () articleDb.serverstatus ()// 查看整个mongodb的状态// 进入admin集合> mongo 127.0.0.1:2222/admin// 查看状态> db.serverStatus()serverStatusA lot of parameters, you can refer to the Db.serverstatus () articleReal-time statistics> mongostat --port 2222Security CertificationsTodoA little complicated, lazy, reference safety
is another way to handle aggregation calculations; Map-reduce typically has two stages: one stage is to process a single document, and the other is to return one or more objects to the next document processing method;
The amount of ..... Well, in short, it's the reduce document result set, summarized by the reduce function;
Reduce don't need me to explain it.
Map-reduce uses idiomatic JavaScript operations for map and reduce operations, so map-reduce flexibility and complexity can be higher tha
MongoDB has been used recently in new projects, so it took some time to learn a bit. This article to their own study to make a summary, intends to use this article as an API in the future, but also to some ready to learn the small partners, hoping to help you.Date:2018-04-25 20:49:12MongoDB Common Commands
MongoDB has been used recently in new projects, so it too
Tags: alt server connect str file--Success Path definition1. Installation Download and install, note the installation method is custom, path customization (D:\CHENGXU\MONGODB), after the installation is successful and then the new Data folder (within the new DB folder) and Logs folder (inside new Mongodb.log file) under the MongoDB folder 2. Server-side Connection CMD window, enter "d:\chengxu\
install MongoDB and server-side configuration http://www.linuxidc.com/Linux/2012-08/68196.htm Ubuntu 13.04 under Install MongoDB2.4.3 http://www.linuxidc.com/Linux/2013-05/84227.htm How to create a new database and collection in MongoDB http://www.linuxidc.com/Linux/2013-06/85749.htm MongoDB entry must read (both concept and actual combat) http://www.linuxidc.co
As the company also has several MongoDB database, need to open a certain portion of the permission for external personnel to use, so here to record, only for the needs of friends to use.1. MongoDB Common Commands[[Emailprotected]~]#ps-ef|grepmongod[[emailprotected]~]#mongo --host=127.0.0.1--port=27017MongoDBshellversion:3.2.7connectingto: 127.0.0.1:27017/test>sho
Tags: mongod class upd ups tables Understand log CREATE DATABASE fieldHere's a record of what MongoDB often commands Database relatedCreate a database Use database_name If the database does not exist, create the database, or switch to the specified database. Delete database : Switch to the database you want to delete, execute the command. Db.dropdatabase () View all databases Show DBS Collection relatedVi
command to start the database
1
mongod --dbpath C:\MongoDb\data\db -logpath C:\MongoDB\data\log\mongolog.log
Common commands for several databases
use DATABASE_NAME // 创建数据库
>db // 检查当前的数据库
mydb
>show dbs // 查询数据库列表
local 0.78125GB
test 0.
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.