Mongodb Study Notes 01 and mongodb Study Notes
Mongodb Overview
Mongodb is a document-type NoSQL database that stores bson-> json binary. The internal execution engine is a js interpreter that stores documents into a bson structure and converts them to js objects during query. And can be operated through js syntax.
Comparison between mongodb and traditional databases
Traditional DatabasesIs a structured database with the same number of Columns
Document DatabaseIn document units
For example:
{ id:1, name: "billvsme", age:21,}
{ id:2, name: "zhangshan", phone:12313, address:23424,}
Can all exist under a table
Document DatabaseThe biggest feature is "no structure". Each document in the table can have its own unique attributes and values.
Column: Comment reply, score, at least multiple tables in the traditional database, the Association is complex, and a document in the document database can be completed
{Title: 'xxxx' comment: [{connent: 'You wrote well !!! ', Reply: ['comments are good', 'Write is good ']}, {connent:' not good at writing ~~ ', Reply: ['approval', 'strongly approval']}
Mongodb Installation
Download the package directly and decompress it to run it.
Https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.4.tgz
Mongodb running mongodb file structure
- Bsondump binary Export
- Mongo client (equivalent to mysql)
- Mongod server (equivalent to mysqld)
- Mongodump overall Database Export
- Mongoexport export is easy to recognize json or csv documents
- Mongorestore import database
- Mongos router (used for sharding)
Start mongod
mongod --dbpath /path/to/database --logpath /path/to/logfile --fork --port 27017
- -Dbpath: database storage path
- -Logpath: Log File Path
- -Port: 27017 by default
- -Fork background running
Test
Enter./mongo directly to mongo.
- Show dbs
- Use database to enter the database
- Show tables/collections View table
- Db. help () help