MongoDB Installation and Basic commands

Source: Internet
Author: User

I am a mongodb installed in CentOS1. Download MongoDBCurl-o http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.6.3.tgz2. Unzip the downloaded documentTAR-ZXVF mongodb-linux-x86_64-2.6.3.tgz3. Installing MongoDB

Cp-r mongodb-linux-x86_64-2.6.3/*/usr/local/mongo

Start MongoDB

The port for MongoDB successfully started is 27017

If you want to start the MongoDB input command in the background (use--fork to specify the--logpath parameter, establish log/in the MONGO directory)

./bin/mongod--dbpath=/data/db--fork--logpath=log/mongodb.log

simple operation of MongoDB

Enable a window to switch to the MONGO directory

Type./bin/mongo Use the MongoDB default client to manipulate data

1.help--mongo Help

2.show DBS; --View all databases

3.show collections; --Displays the collection in the current database (similar to a table in a relational database)

4.use dbname;--Switch database

5.db.getname (); --View the current database name

6.db.stats (); --Displays the current DB status

7. Db.getmongo (); --View the link machine address of the current DB

Collection Aggregation Collection

1. Create a Clustered collection (table)

Db.createcollection ("Collname", {size:20, Capped:5, max:100});

2. Get a clustered collection with the specified name (table)

Db.getcollection ("account");

3. Get all the aggregation sets for the current DB

Db.getcollectionnames ();

4. Displays the status of all clustered indexes in the current DB

Db.printcollectionstats ();

MongoDB Installation and Basic commands

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.