Document directory
- Download and install mongdb
- MongoDB drivers
Nosql has been popular for a while, and I seem to be a little late. There are many nosql products, and MongoDB is only one of them. The reason why I chose to learn MongoDB is because she was the first to know and representative. MongoDB has some advantages over traditional relational databases, such as performance and good scalability of massive data. The biggest difference between MongoDB and relational databases is that there is no relational model in relational databases. More accurately, it is a document-oriented database. In general, in MongoDB, the table corresponding to the relational database is integrated, and the document corresponds to the line. The format of a record in MongoDB is bson, which is similar to JSON in JavaScript. As follows:
Download and install mongdb
: Http://www.mongodb.org/downloads.
- Bsondump: Dump bson files into JSON data
- Mongo: the client command line tool is actually a javascript interpreter that supports JavaScript syntax.
- Mongod: database server. Each instance starts a process and can run fork on the background.
- Mongodump/mongorestore: database backup and recovery tools
- Export export/Export Import: data export and import tool
- Program Files: gridfs management tool for Binary File Access
- Mongos: shard routing. If sharding is used, the application is connected to Mongo instead of mongod.
- Mongosniff: this tool is similar to tcpdump. The difference is that it only monitors MongoDB-related packet requests and outputs data in a specified readable form.
- Mongostat: real-time performance monitoring tool
To use mongodbas, you must first start the mongodbservice, open the BINLOG of mongodbas, and execute mongod.exe, as shown below:
We can see that mongod.exe is followed by a-dbpath to define the database storage path. This directory must be created in advance. If-dbpath is not specified, the default path c: \ data \ dB \ is used \. You can open the shell window.
Run the show DBS command to view the list of all databases. For more shell commands, run the Help Command.
Admin and local databases are MongoDB databases, which have special functions in the system.
- Admin: a database with the highest permissions. users in the database have permissions for all databases. Some special server commands can only be run from this database.
- Local: the database will not be copied and can be used to store any set of limits and a local single server.
There is no command for creating a database in the shell command of MongoDB. If you want to create a database named blogs and add a set and a document to the database, we can do the following: 1. Run the use blogs command to switch the database to blogs. Of course, blogs is not created yet. 2. Create a data record and save it in a variable post. Execute dB. Blogs. insert (post ).
At this time, you can see that the database file has been produced in the path set above:
For more shell commands, refer to the following article.
MongoDB drivers
To use MongoDB in a program, you need to go to the MongoDB driver for a specific language. On the MongoDB official website, you have provided drivers for Ruby, Python, C #, PHP, and other languages. Driver list page: http://www.mongodb.org/display/DOCS/Drivers C # driver download: A Brief Introduction to MongoDB https://github.com/samus/mongodb-csharp here, the following articles will use C # To write a complete example.