MongoDB Learn the second---run the MONGO command through the Shell under Mac

Source: Internet
Author: User

After a short essay, the installation of MongoDB can be done after the most basic database operation, the following steps to achieve your Hello world!

1. Open terminal Execution Brew services start MongoDB start MongoDB service, execute MONGO open shell operation;

2. Show All DB: show dbs

3. Enable a DB: Use mydb (if no mydb will automatically create this library)

4. Display the table in the library:Show Tables or show Collections (in MongoDB, table is called collection)

5. Insert a piece of data: db mycollection insertone ( { x : 1 Span class= "p" > );   (This table will be created automatically if not mycollection)

< Span class= "NX" >6. Query all the data in the table: db.mycollection.find ()   (all of MongoDB's data is stored in the form of a document (JSON) in collection < Span class= "NX" > ) /span>

7. Query all the data in the table, beautiful typesetting display:db.myCollection.find (). Pretty ()

8. Use tab code hint: input db.my click tab Key, will complete the code automatically; input db.mycollection.c click tab The key will prompt all fuzzy instructions, the manual knocking command completes.

9. Exit the shell operation: quit () or <control-C> shortcut key

MongoDB Learn the second---run the MONGO command through the Shell under Mac

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.