MongoDB Note A--MONGODB basic environment configuration and additions and deletions to check;

Source: Internet
Author: User

First, the basic Environment configuration;

1, first to the official website (http://www.mongodb.org/downloads) Download the appropriate installation package, and then step by step next installation, of course, you can change the installation directory; After the installation is complete, configure the environment variables to find the Bin folder under the installation directory. In the computer environment variable, add its path (D:\MongoDB\bin, I installed in the D disk);

2, set up a directory for storing database files; Windows uses C:\data\db as the data directory by default. However, during the installation process, files or folders will not be created automatically, and you will need to create them yourself. Of course we can also create the file directory anywhere in the system, and then use the command--dbpath to set the data directory.

Mongod--dbpath  Path

Create a new file directory in the D drive;

d:\>mkdir mongodbdatad:\>cd mongodbdatad:\mongodbdata>mkdir db

Of course, you can also set up without the command line;

3, use the command to specify the data storage directory;

Mongod--dbpath D:\MongoDBDATA\data

When you see this line "Waiting for connections on port 27017", enter http://localhost:27017/in the browser and you're done!

It looks like you is trying to access MongoDB over HTTP on the native driver port.

Second, the basic API additions and deletions to check;

1, CREATE database: Use[database];

Use test

2, view all databases;

> show dbslocal  0. 000GBtest   0.000GB

3, add a collection to the specified database and add records;

Db.persons.insert ({name: ' Jone '})

4. View all documents in the database;

Show collections

5, query the data of the specified document;

>"_id": ObjectId ("5714D7331BF2E414603681DF"), "name": "Jone"}

The FindOne () method can query the first one;

6, update the document data;

Db.persons.update ({name: ' Jone '},{$set: {name: "Eric"}})

7, delete the document data;

Db.persons.remove ({name: "Eric"})

MongoDB Note A--MONGODB basic environment configuration and additions and deletions to check;

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.