1. Download MONGO: Curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.6.tgz
2. Unzip: tar -zxvf mongodb-linux-x86_64-3.0. 6.tgz
< Span class= "PLN" >3. Renaming: MV mongodb-linux-x86_64-3.0.6//usr/local/mongodb
< Span class= "PLN" >4. Add environment variable: export=<mongodb-install -directory>/bin:< Span class= "PLN" > $PATH , Source/etc/profile re-entry into force.
5. Create a new database directory: mkdir -p /data/db,/data/db is the default startup database path for MongoDB
6. Start MONGODB:CD <mongodb-Install-directory>/bin into the bin directory, run:./mongod
7. Open a new command window, also into the bin directory, run./mongo into the MONGO shell
8. Syntax:
< Span class= "PLN" >< Span class= "pun" > New database Runoob:use runoob, switch to Database Runoob, the next time the data is written: db. runoob.insert ({"Name": " Insert Data "}" to create the database automatically.
Delete the database runoob:use runoob, switch to the database you want to delete, and then run: db. Dropdatabase()
Update data:db.runoob.update ({' Conrolname ': ' Value '},{$set: {' updatetitle ': ' Updatevalue '}}), this statement only modifies the first found document , if you want to modify more than one document, you need to add the following settings {Multi:true}
Save () Method: Db.runoob.save ({"_id": "Value", "title": "Value"}), overriding for all values.
Delete data: Db.runoob.deleteMany ({"title": "Value"}), delete multiple data, Db.runoob.deleteOne ({"title": "Value"}), delete one piece of data
Query data:db. Runoob. Find(). Pretty(), FindOne () returns a single piece of data.
Db.runoob.find ({$or: [{"Title1": "Value1"},{"title2": "Value2"}]}). Pretty (), conditional or query.
Db.col.find ({"likes": {$gt: $}, $or: [{"By": "Rookie Tutorial"},{"title": "MongoDB Tutorial"}]}). Pretty, where likes>50 and (by = ' Rookie Tutorial ' ' OR title = ' MongoDB tutorial ') '
Linux: Installing and using MONGO