Installation and use of MongoDB under Win7

Source: Internet
Author: User
Tags first row

Installation and use of MongoDB under Win7

1. Download:

Http://www.mongodb.org/downloads

2. Installation:

Installation directory is D:\mongodb\MongoDB 2.6 standard

Configure the environment variable path to D:\mongodb\MongoDB 2.6 Standard\bin

D:\mongodb\ Create a Data folder to hold the database files

3. Start the server:

CMD under input mongod.exe--dbpath d:\mongodb\data

If you start, you will see a prompt similar to the following:
...
[Initandlisten] MongoDB starting:pid=7476 port=27017 Dbpath=d:\mongodb\data
...
[Initandlisten] Waiting for connections on port 27017

Do not turn off the server when it is turned on.

4. Start the client:

Open a new CMD console and enter the command Mongo.exe

If you successfully connect to the server, you will see a prompt similar to the following:

MongoDB Shell version:2.6.5
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
>

5. Operation Database:

Show all databases
Show DBS

Show all tables under the current database
Show collections

Inserting data into the x123 table (automatically created if the table does not exist)
Db.x123.insert ({name: ' abc123 ', Age: ' 20 '})

Show all data in the x123 table
Db.x123.find ()

Conditional query
Db.x123.find ({"Test5": "OK"}). Limit (1);

Delete data with Name field ' abc123 '
Db.x123.remove ({name: "abc123"})

Update action
Db.x123.update ({"Count": {$gt: 5}},{$set: {"Test5": "OK"}},true,true);

More commands are as follows:

Use a specific DB
Use Xxdb;

Deleting the specified database must now be used xxdb again
Db.dropdatabase ();

Delete Collection
Db.xxcollection.drop ();

View Records in collection
Db.xxcollection.find ();

Deleting records
Db.xxcollection.remove ({_id:xxx});

Export data, data format as JSON
Mongoexport--port 10240-d xxdb-c xxcollection-o xxcollection.dat;

Export data in CSV format (comma-separated values)
Mongoexport--port 10240-d xxdb-c xxcollection-csv-f uid,username,age-o xxcollection.dat;

Import data, data format as JSON
Mongoimport--port 10240-d xxdb-c xxcollection-o xxcollection.dat;

Import data, data format CSV, do not import the first row (the Behavior column name)
Mongoimport--port 10240-d xxdb-c xxcollection--type csv--headerline-file user_csv.dat;

Query a record
Db.xxcollcetion.findOne ();

Query a specified number of records
Db.xxcollection.find ({xxx:xxx}). limit (n);

Sort
Db.xxcollection.find ({xxxx:xxxx}). Sort (' date ', 1);
  
Pagination
Db.xxcollection.find ({memberid:test}). Skip (20n). Limit. Sort (' date ', 1);

6. Visualization Tools:

Reference: http://docs.mongodb.org/ecosystem/tools/administration-interfaces/

7. Operation MongoDB in C #:

Reference: Https://github.com/mongodb/mongo-csharp-driver/downloads

Add "MongoDB Install and Boot with Windows":
Create a new logs folder inside D:\mongodb
Create a new Mongodb.log file inside the logs folder
Open the cmd window and enter the following command:
Mongod--dbpath D:\mongodb\data--logpath=d:\mongodb\logs\mongodb.log--install
Then enter the following command:
net start MongoDB
Shown below:
The MongoDB service is starting.
MongoDB Service has started successfully.
Then start MongoDB in the service
If it is Win7, then start cmd to start with the administrator.
In addition, the visualizer NoSQL Manager for MongoDB works well!

Installation and use of MongoDB under Win7

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.