Installing MongoDB under Linux

Source: Internet
Author: User

1. Download MongoDB
wget http://downloads.mongodb.org/linux/mongodb-linux-i686-2.4.9.tgz
( you can go to the official website to download http://www.MongoDB.org/downloads)
2.unzip the MongoDB tar Zxvfmongodb-linux-i686-2.4.9. tgz
3. Create the specified folder and copy the MongoDB to the past mkdir-p/usr/local/MongoDB CP-R mongodb-linux-i686-2.4.9/*/usr/local/mongodb/
4. Create a database hosting directory and log storage filesMkdir-p/data/mongo/data Touch/data/mongo/dblogs
5. Start Mongod/usr/local/mongodb/bin/mongod--dbpath=/data/mongo/data--logpath=/data/mongo/dblogs--logappend--fork (//--fork is for the program to be executed in the background)6. Set up boot from bootEcho/usr/local/mongodb/bin/mongod--dbpath=/data/mongo/data--logpath=/data/mongo/dblogs--logappend--fork > >/etc/rc.local7. Close the Mongod process:
Pkill MongodCommon parameter descriptions for startup commands:--DBPATH Specifies the directory where the database file resides--port specifies the port default 27017--fork settings used by the Mongod service MONGO service for background run--logpath Specify the log file directory and the file name--logappend is set every time log is added at the end of the file--journal enable log--pidfilepath Specify the path of the process file, if not specified, the system will not produce the maximum number of concurrent connections to the process--maxconns --noprealloc turn off the pre-distribution of data files--rest Close the Rest API feature--nohttpinterface turn off Web management features--auth specify MONGO use authentication mechanism --BIND_IP Binding IP

MongoDB Basic Commands
*View Database
Show DBS | show databases;

* View Current database
db | Select Database ();

* CREATE DATABASE
Use test1 | CREATE DATABASE Test1
Note that it is not possible to show DBS in this time. An empty database needs to add at least one file Db.movie.insert ({"Test": "Test"})

* Switch Database
Use test1 | use test1

* Delete Database
Enter Database Db.dropdatabase | Drop database Test1



* Create a table
Db.xxx.insert () Call document | CREATE TABLE xxx;

*
Check Table
Db.xxx.find or FindOne | select * FROM XXXX

Installing MongoDB under Linux

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.