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.
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
For initial installation, a database such as the one shown below will appear
(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
2: Collection
(1) Create a collection
Db.createcollection ("Set name: such as (mycollection)") |
Results:
(2) View collection
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