MongoDB initial experience

Source: Internet
Author: User
Tags mongodb query mongodb server

To put it simply:

MongoDB is a document-oriented database system. It is written in C ++ and does not support SQL

Use bson as the data storage and transmission format. Bson is a JSON-like binary serialization document that supports nested objects and arrays.

MongoDB is similar to MySQL. document corresponds to MySQL row and collection corresponds to MySQL table.

1. Start the server first

Mongod.exe -- dbpath K;/date (the specified directory must be created first, so no error is reported)

2. Start the client

Cmd.exe
(There is a default database test in the database)

Show DBS show all databases

DB. user creates a table

DB. User. Save ({name: "lei", sex: "boy"}) adding a user to a user is equivalent to "insert ".

DB. User. Find () to view all data in the table

3. Create a new database

Use student (if student does not exist, create the student library ).. If no data is inserted, the database name is not displayed.

(Well, The MongoDB query statement will not be written ).. Go home and check the comparison between the query statement and MySQL...

4. MongoDB security and authentication (permission)

In MongoDB, we can specify permissions for specific sets or documents (of course, it seems useless to have an administrator admin set and document permissions)

1. Create a user dB. Student. adduser ("1", "1 ")

2. Specify a permission user dB. Student. Auth ("1", "1") for this table ")


5. data import and everywhere (For MySQL databases)

1. import data from MySQL to MongoDB.

2. Export data in MongoDB


6. Make the MongoDB server a "service" of the system"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.