Ubuntu Install MongoDB Database

Source: Internet
Author: User
Tags install mongodb

First step: Download the installation package

Download version: 3.0.1

Download Link:http://www.mongodb.org/downloads

First, unzip the installer in Linux

Operation by Command:

Decompression: [Root@localhost soft]# TAR-ZXVF mongodb-linux-i686-3.0.1.tgz

The decompression process is as follows:

We renamed the mongodb-linux-i686-3.0.1.tgz unpacked folder to MongoDB .

We put a new data directory in the MongoDB directory to hold the information, create a new log directory to hold the log, and then create a new log file under the directory, for example, we named Mongodb.log

DOS Code

    1. [Email protected] mongodb]# mkdir log

    2. [Email protected] mongodb]# mkdir data

    3. [[Email protected] mongodb]# CD log

    4. [email protected] log]# Touch Mongodb.log

and navigate to the Mongodb/bin directory.

Use the Mongod command to establish a MongoDB database link with the port number set to 100001 (default port is 27017), the database path is/mongodb/data, and the log path is/mongodb/log/mongodb.log

Start Command :

DOS Code

    1. [email protected] mongodb]#/bin/mongod-port 10001--dbpath data/--logpath log/mongodb.log

Use the client to connect to the database

Re-open a terminal and switch to the MongoDB directory:

DOS Code

    1. [Email protected]/]# CD Usr/local/mongodb

Then use the Bin/mongo command to connect to the database

DOS Code

    1. [Email protected] mongodb]#./bin/mongo localhost:10001

    2. MongoDB Shell version:3.0.1

    3. Connecting To:localhost:10001/test

    4. >

Inserting values into the database

DOS Code

    1. Connecting To:localhost:10001/test

    2. > Db.foo.save ({A:1})

Querying from the database

DOS Code

    1. > Db.foo.find ()

    2. { "_id": ObjectId ("4ee66eb440ef7803a9873d2d"), "a": 1}

    3. >

Access via browser

In the browser address bar, enter: http://localhost:10001/ and then enter to access

You can see the following tip: It looks like you is trying to access MongoDB over HTTP on the native driver port.


Configuring MongoDB with configuration Files

First create a new file in the MongoDB directory, the file name arbitrary, here I named: mongodb.conf

DOS Code

    1. [Email protected] mongodb]# VI mongodb.conf

Then add the configuration information in the configuration file

TXT code

    1. port=10001

    2. dbpath=data/

    3. Logpath=log/mongodb.log

    4. Logappend=true

Explanatory notes:

Port=10001 "represents the port number and defaults to 27017 if not specified "

dbpath=data/"Database Path"

Logpath=log/mongodb.log "Log Path"

Logappend=true "Log files automatically accumulate, not overwrite"

Start MongoDB Service   

DOS Code

    1. [Email protected] mongodb]#/bin/mongod-f mongodb.conf

    2. All output Going To:log/mongodb.log

and then access the same way as before.

Ubuntu Installation MongoDB database

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.