MongoDB introduction:
Non-relational databases are mainly used to solve the following problems:
A) High database concurrency requirements
B) Demand for efficient storage and access to massive data
C) high scalability and availability requirements for Databases
Disadvantages:
A) Database Transaction consistency requirements
B) database write timeliness and read timeliness requirements
C) complex SQL queries, especially multi-table join queries
Differences between MongoDB and relational database storage:
1. Download MongoDB
Http://www.mongodb.org/downloads when I sent this blog I used 1.8.2, using Linux 64-bit
2. Run Server
Decompress the downloaded MongoDB file, decompress it to/usr/local/MongoDB, and start the/bin/mongod server.
Below are some parameters I added during startup:
You need to create two folders: data and data/MongoDB (this may be the main reason why you cannot afford the MongoDB service)
./mongod -dbpath=../data/mongodb -logpath=../data/mongodb/mongodb.log -directoryperdb>/dev/null 2>&1.
--> Parameter explanation: dbpath (data storage directory) logpath (Log Path) directoryperdb (each database is stored in a different directory)
3. Run MongoDB
It's easy to run. Run/bin/Mongo directly.
4. Simple SQL Testing
> Show DBS ---> query the current database admin (empty) Local (empty)> use crazy --> switch the database at will, switched to DB crazy> show DBS --> View crazy database again. Admin (empty) Local (empty)> dB is not created. crazy. insert ({A: 3, B: 5}) -- insert data to the crazy table in the crazy database> show DBS admin (empty) crazy 0.203125 GB -- crazy database created successfully local (empty)> dB. createcollection ("baby") -- create the baby data table {"OK": 1}> show collections babyblogsystem. indexes> dB. crazy. find () -- Query all data in the crazy table {"_ id": objectid ("4d99dc8a6c0c727c06c3b618"), "A": 3, "B": 5}
> Use tutorial -- unmount a database first, go to switched to DB tutorial> dB. dropdatabase () -- unmount {"dropped": "tutorial", "OK": 1}
Create collection: DB. createcollection ('good ')
For other usage, use help and DB. Help ()