Mac next to MongoDB connection

Source: Internet
Author: User
Tags install mongodb mongodb tutorial

Not so much chicken soup, start connecting it ~


See a quick-start MongoDB tutorial on the Web, put an address note under ~


One: Connection

In the previous section we installed the MANOGODB, if you successfully installed the words ~ Then, the new open terminal, enter the following instructions to connect.

Mongo

Appears as shown below, well, you're successful-you can do it on the command line.

MongoDB Shell version:3.2.8

Connecting To:test

welcome to the MongoDB shell.

For interactive help, type ' help '.

For more comprehensive documentation, see

http://docs.mongodb.org/

Questions? Try the support group

http://groups.google.com /group/mongodb-user

Server has startup warnings:

2016-08-02t19:16:07.239+0800 I CONTROL  [ Initandlisten]

2016-08-02t19:16:07.239+0800 I CONTROL  [initandlisten] * * warning:soft rlimits too low. Number of files is a, should be at least

>

>

>

If you do not install MongoDB successfully, you may get the following error.

MongoDB Shell version:3.2.8

Connecting To:test

2016-08-02t18:14:33.677+0800 W NETWORK [Thread1] Failed to connect to 127.0.0.1:27017, reason:errno:61 Connection refuse D

2016-08-02t18:14:33.678+0800 E QUERY [thread1] error:couldn ' t connect to server 127.0.0.1:27017, connection attempt FA Iled:

[Email protected]/mongo/shell/mongo.js:229:14

@ (Connect): 1:6


Exception:connect failed

So, the failure of the ~ reference to the previous section ~ in the installation bar ~


Second: Adding and deleting changes

1: Database

(1) Querying existing databases


Show DBS

For initial installation, a database such as the one shown below will appear


Local 0.000GB

(2) Installing the database

Use database name (for example: test)

If you have a database with the same name, you can switch to an existing one without creating a new

Switched to DB test

2: Collection

(1) Create a collection

Db.createcollection ("Set name: such as (mycollection)")

Results:

{"OK": 1}

(2) View collection

Show collections

Results:

MyCollection (the collection name created)

3: Add: Insert (for example, set mycollection)

Db.mycollection.insert ({name: "Liujinhuan"})

Results:

Writeresult ({"ninserted": 1})

4: Search: Find (Take the set mycollection as an example)

Db.mycollection.find (). Pretty ()

Results:

{"_id": ObjectId ("57a0871725ae4f21a42b44e3"), "name": "Liujinhuan"}

5: Change: Update (Take the set mycollection as an example). Modify name is Liujinhuan for TTTTTT

Db.mycollection.update ({' name ': ' Liujinhuan '},{$set: {' name ': ' Tttttt '}})

Results:

Writeresult ({"nmatched": 1, "nupserted": 0, "nmodified": 1})

6: Delete: Remove (take the set mycollection as an example)

Db.mycollection.remove ({"Name": "Liujinhuan"})

Results:

Writeresult ({"nremoved": 1})


Three: visual Operation tools

All of these are input instructions executed in the terminal ~ Recommend a visual action tool robomongo~


It's too late ~ tomorrow morning Checkup ~ Early Sleep ~


This article is from the "Cinderella" blog, please be sure to keep this source http://cinderella7.blog.51cto.com/7607653/1833720

Mac next to MongoDB connection

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.