First, start the MongoDB shelltool, that is, bind the cmd.exe
Common shell commands are as follows:
1. query the names of all local databases
> show dbs;
2. Switch to the specified database environment (if no database is specified, a new database is created)
> use dbtest;
Switch to the dbtest database or create a database named dbtest.3. query all collection sets in the current database (equivalent to table)
> show collections;
4. Create a collection
Mongodb Study Notes 02 and mongodb Study NotesMongodb Study Notes 02-CURD operations
CURD indicates Create, Update, Read, and Delete operations.
Create a database Directly use the database name and create a collection to create a database.
Create collecion
db.createCollection("collectionName")
Create collection implicitly
db.collectionName.insert({xxxxxx})
Delete collection
db.collectionName.drop()
Basic use of mongoDB (II), use of mongodbConnect to the mongoDB server for basic database operations./bin/mongo 127.0.0.1: 12345View the current database> show dbsadmin (empty) local 0.078GBut change the database (it will be automatically created if it does not exist)> use jeromeswitched to db jeromeDelete database> db. dropDatabase () {"dropped": "jerome", "OK": 1}Delete table
12345678910
>>sho
Mongodb Study Notes 07: mongodb Study Notes
Export export in json or csv format
Using import to import json or csv
Mongodump exports binary bson structure data and index information
Mongorestore imports binary files
Mongoexport
-H host -- port number-u user name-p password-d database name-c table name-f field1, field ..... export field-q query condition-o export file name -- csv is equivalent to -- t
Mongodb Study Notes 05 and mongodb Study NotesEnable authentication
Mongod does not have the permission to start by default. You need to specify-auth to start, or set security. authorization to "enabled" in the configuration file"Create user
Db. createUser (user, writeConcern)
Document http://docs.mongodb.org/manual/reference/method/db.createUser/#db.createUser
User format
{ user: "
WriteConcern:
For exa
To see which databases are available:Show DBSSwitch to that library:Use library name Use LocalUse also has a function of "Create a Database" Use testTo delete a database:Db.dropdatabase ();To view a collection:Show collectionsTo create a collection:Db.createcollection ("user");Implicitly created, inserted directly into the collection, she will automatically create the collectionDb. user. Insert ({ID:1, Name: "Lisi"});To delete a collection:Db. user. Drop ();Insert:Db. user. Insert ({ID:1, Name:
10) db.char.find ({' name ': ' Weixiaobao '}). Skip (2). Limit (10)f) The query returns the number of bars Db.char.find ({' name ': ' Weixiaobao '}). Count ()g) sort (by name ascending, age descending) Db.char.find (). Sort ({' name ': 1, ' age ':-1})h) Query the specified column to db.char.distinct (' name ')i) Remove the set Db.char.drop ()j) Create index Db.char.ensureIndex ({' Name ': 1, ' Age ': 1},{unique:true})k) View index db.char.getIndexes ()L) Delete index Db.char.dropIndex (' IndexN
Tags: 9.png support difference God sharing interface images PNG selectionThe user writes the data using the interface provided by the database, and the data is stored in a standard format.Different database differences: The organization of the data is different, while providing different types of queries, users according to their own needs to choose the appropriate database.You can store your geographic location in MongoDB, such as searching for nearb
1. Use or create a database:Use WandrecorderYou'll use the keyword to create or fetch a exicting database.2. Find all documents in the database.Db.wands.find ()You already start with DB Keywrod. Then follow your collection name, where is ' wands ', find () method would return all the documents in that collection.3. Insert document to the collections:Db.wands.insert ({name: ' Dream Bender ', Creator: ' Foxmond '})Use Insert () Metod to inserts JSON data to the collection as a document.4. Find a v
Optime: Read Oplog.rs collection. The last time the instance was changed.MongoDB uses lastheartbeat for automatic transfer.The Mongod instance sends a heartbeat packet to the other members every two seconds, and the member's state is judged by the health of the member returned in Rs.status (). If the primary node is unavailable, then all secondary nodes in the replication set will trigger an election operation. Select the new primary node. If there are multiple secondary nodes, the node that ha
before the copy is completed and then write Oplog, it is possible that the same operation will synchronize two copies, However, MongoDB at the beginning of the design to consider this problem, will oplog the same operation executed multiple times, and the effect is the same as the execution once.The growth rate of 3:oplogOplog is a fixed size, he can only save a specific number of operation logs, usually oplog use of space growth rate with the system
/*** MongoDB $type operator*/
/*** The $type operator is based on the Bson type to retrieve the matching data type in the collection and returns the result.* The types of MongoDB that can be used are shown in the following table:* Type Number Notes* Double 1* String 2* Object 3* Array 4* Binary Data 5* Undefined 6 is obsolete.* Object ID 7* Boolean 8* Date 9* Null 10* Regular Expression 11* JavaScript 13* S
Label:OverviewThis article mainly describes the method of installing MongoDB on Windows systems.MongoDB Official website: http://www.mongodb.org/, the latest version is 2.6.7.Attention:Starting with version 2.2, MongoDB does not support Windows XP. Please use the latest version of Windows to use the latest version of MongoDB.If you are running any version of Windows Server R2 or Windows 7, install the hotfi
Install MongoDB on CentOS7
Install MongoDB on CentOS7
1. Connect to the CentOS7 server through SecureCRT;
2. Go to the/usr/local/directory:Cd/usr/local
3. Create the tools directory in the current directory:Mkdir-p tools
4. Go to the tools directory:Cd tools
5 download the mongodb-linux-x86_64-rhel70-3.2.4.tgz file that matches the CentOS system:Wget https://fast
MongoDB supports multiple languages and is driven by multiple languages.
Java MongoDB operations to achieve curd: premise: Download the corresponding driver: download on the official website: http://central.maven.org/maven2/org/mongodb/mongo-java-driver/ I use mongo-2.10.1.jar version: the following code in detail, each method can be executed separately. In order
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.