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