A. MongoDB installation
1. First download its installation package http://www.mongodb.org/on the official website of MongoDB. Download it according to your operating system.
2. Establish two directories on the hard disk to store MongoDB installation files and data files, for example, I created:
D:\mongodb and D:\mongodbdata
Unzip the downloaded installation package and copy the extracted items to the D:\mongodb.
3. Start cmd (win+r key, cmd) to switch to the Bin folder in D:\mongodb.
Input command: Mongod.exe--dbpath D:\mongodbdata the database is installed.
4. Configure the environment variables. Add D:\mongodb\bin to Path
5. You can enter mongod-help in cmd to view Mongdb's help.
Two. Start the database
Create a new BAT file (to open the database file):
Input content: Mongod--dbpath D:\mongodbdata
Create a new BAT file (Database operations file):
Input content: MONGO 127.0.0.1:27017/admin
It means to access the database port number 27017 (the default port) via the 127.0.0.1 URL, with Admin user access
Three. Comparison of databases
Four. Simple operation of the database
1. New database use [DbName]
[DbName] is the name of the database. The database is not saved if the database is not operational after the new database is created
2. Add a collection to the database (you can understand it as a new table) and add a record (adding data to the table)
Db.persons.insert ({name: "Zhangsan"})
3. Querying all the databases
Show DBS
4. Querying documents in the database
Show collections
5. Querying data in a database document
Use the Find () method or the FindOne () method
6. Modify the Database
Db.persons.update ({name: "extjs4.0"},{$set: {name: "extjs4.1"}})
Similar to that in SQL
Update persons Set name = ' extjs4.1 ' WHERE name = ' extjs4.0 '
7. Delete Data
Db.persons.remove ({name: "extjs4.0"})
Example: