MongoDB Database Practice Notes

Source: Internet
Author: User

MongoDB Operation rules

Download the installation files from the Web site
Then create the folder in the installation directory data and log
Creating a configuration file Mongo.config
The inside padding is as follows:

# #数据文件
Dbpath=d:\mongodb\data
# #日志文件
Logpath=d:\mongodb\log\mongo.log
# #错误日志采用追加模式, after configuring this option, the MongoDB log is appended to the existing log file instead of creating a new file


Start MongoDB
Start the following command under the cmd command
D:
CD D:\MongoDB
CD bin
Then enter Mongod--config d:mongodb\mongo.config
Do not close this window
Then click on file Mongo.exe in the bin directory to

Create several libraries

>use database name
Then appear
switched to DB database name
>db
Database name

View all databases
>show DBS is available.
But the database you just created is not shown here because there is no data

We want to see, of course, inserting data
>db.myblog.insert ({' Bid ': 1, ' bname ': ' Alan '})
Then appear
Writeresult ({"ninserted": 1})

View Database
>show DBS
Blog

At this point we can view the created table
>show Collections
MyBlog

You can also create tables like this
>db.createcollection ("MyTest") enter
{"OK": 1}
Continue to view
> Show Collections
MyBlog
MyTest

Querying data
>db.myblog.find () Enter to see the data you just inserted
{"_id": Objiectid ("57414249dd1a4ffc85e11928"), "bid": 1, "bname": "Alan"}

MongoDB Database Practice Notes

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.