MongoDB installation under Windows, Shell client usage, Bson expanded data types, Mongovue visualizer installation and simple use (2)

Source: Internet
Author: User
Tags findone mongodb client windows download

One, Windows download installation

1. To http://www.mongodb.org/downloads download, MongoDB is installed by default in C:\Program Files\mongodb directory, to F:\Office\Database\ Mongodbdata New Mongodbdata directory is used to store mongodb data.

Execute cmd command

Executive Mongod.exe

2. Setting Environment variables

Go to the Windows environment variable to add C:\Program files\mongodb\server\3.0\bin to the path variable, and then cmd to use C:\Program without a specific path files\mongodb\ Server\3.0\bin below the Mongod.exe

3. Start the database service

New Mongodb.bat file, contents: Mongod--dbpath F:\Office\Database\MongoDBDATA

4. Start the configuration file for the database service

MongoDB Start Command mongod parameter description

Http://www.uspcat.com/forum.php?mod=viewthread&tid=7722&extra=page%3D1

Second, the Shell basic operation, the equivalent of MongoDB client

Start the shell client

New Mongo27017.bat, Content: MONGO 127.0.0.1:27017/admin, note that both the server and the client are running as administrator, otherwise they will not be able to connect to MONGO 127.0.0.1:27017

1. Create a database

Use [DatabaseName] but if you leave without doing anything, the empty database will be deleted.

2. Add a collection to the specified database and add records

Db.  [Documentname].insert ({...}) For example: Db.persons.insert ({name: "YXL"})

3. View all databases

Show DBS

4. View all documents in the database

Show collections

5. Querying data for a specified document

Query all: DB. [Documentname].find () Example: Db.persons.find ()

Query the first piece of data: db. [Documentname].findone () Example: Db.persons.findOne ()

6. Updating document data

Update YXL1 to ask YXL2

Db.persons.update ({name: "YXL1"},{$set: {name: "Yxl2"}})

The document that represents the query name: "YXL1" is changed to name: "YXL2"

7. Delete data from a document

Db. [Documentname].remove ({...})

Example: Db.persons.remove ({name: "YXL2"})

8. Delete a collection from the library

Db. [Documentname].drop ()

9. Deleting a database

Db.dropdatabase ()

Help for 10.Shell

There are all the commands that the shell can do to help

Global Help database related to the DB.HELP () collection-related db. [Documentname].help ()

API for 11.mongoDB

http://api.mongodb.org/js/

Database and collection naming conventions

    1. Should all lowercase
    2. Maximum of 64 bytes
    3. The database name cannot have the same name as the existing system reserved library, such as admin,local, and config

Such collection names are also legal, but individuals do not recommend the use of

Db-text, but not through DB. [DocumentName] got, to be changed to Db.getcollection (DocumentName)

Because the db-text will be treated as a subtraction operation.

MongoDB's shell built-in JavaScript engine can execute JS code directly

function Insert (object) {

Db.getcollection ("Db-text"). Insert (object)

}

Insert ({name: "YXL"})

The shell can use eval

Db.eval ("Return ' YXL '")

Third, Bson expanded data types

Iv. Mongovue Visualization tool installation and simple use

MongoDB installation under Windows, Shell client usage, Bson expanded data types, Mongovue visualizer installation and simple use (2)

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.