Linux under MongoDB client Shell basic operation

Source: Internet
Author: User
Tags mongodb client

MongoDBis a NoSQL database, there is no fixed pattern, that is, the same set of different document structure can be different, such as: the first record {name: "Xiaoming"}, the second record: {name: "Xiaoli", age:15}, which is not possible in the relational database. For MongoDB, Where: Collections is the collection of tables that are equivalent to relational databases, and document documents are equivalent to rows in a relational database. So that is to say, the data stored in a table in MongoDB can be non-defined type, etc. Let's take a look at some of the basic operations of MongoDB's own shell client.
Let's take a look at how to open the client shell. If MONGODB is configured into the environment variable of the system, it can be entered directly at the command line: 1, Shell login MongoDB Client If no environment variable is configured, go directly to the installation directory to log insuch as my installation directory is in/home/lutong/mongodb/bin/mongo MongoDBis a NoSQL database, there is no fixed pattern, that is, the same set of different document structure can be different, such as: the first record {name: "Xiaoming"}, the second record: {name: "Xiaoli", age:15}, which is not possible in the relational database. For MongoDB, Where: Collections is the collection of tables that are equivalent to relational databases, and document documents are equivalent to rows in a relational database. So that is to say, the data stored in a table in MongoDB can be non-defined type, etc. Let's take a look at some of the basic operations of MongoDB's own shell client.
Let's take a look at how to open the client shell. Note: First to open the service Oh, No. Children's shoes see this article (Two ways to login MongoDB under Linux) if you configure MongoDB into the environment variable of the system, you can enter it directly at the command line: 1, Shell login MongoDB Client If there is no environment variable configured, Then go directly to the installation directory and log in.such as my installation directory is in/home/lutong/mongodb/bin/mongo

Shell Basic Operations 2, view all databases show DBS

3. Create a database use [database] (Note: If database does not exist, it will create one, if you do not do anything directly exit, MongoDB will delete the database)

4. Add the document record db to the specified database. [Collectionname].insert ({...}) 5, find all document records and first document record 6, update a document record db. [Collection].update ({query condition},{$set: {update content}})

7. Delete the data db from the collection. [Collection].remove ({delete condition})

8. Delete the collection db in the database. [Collection].drop ()

9. Delete Database Db.dropdatabase ()

Linux under MongoDB client Shell basic operation

Related Article

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.