Install MongoDB in Linux

Source: Internet
Author: User
Tags install mongodb

How does one install the MongoDB database in Linux? Follow these three steps to install MongoDB in Linux.

Read more: Install and start MongoDB in Linux

Step 1: download an object
For 32-bit linux
$ Curl http://downloads.mongodb.org/linux/mongodb-linux-i686-1.4.4.tgz> mongo. tgz
$ Tar xzf mongo. tgz
For 64-bit linux
$ Curl http://downloads.mongodb.org/linux/mongodb-linux-x86_64-1.4.4.tgz> mongo. tgz
$ Tar xzf mongo. tgz
If curl Is Not Installed
Install apt-get install curl first
Step 2: create a data folder
By default, MongoDB stores data in the/data/db/folder, which needs to be manually created.
Create an ECS instance as follows:
$ Adduser mongodb
$ Passwd mongodb
$ Sudo mkdir-p/data/db/
$ Sudo chown 'id-U'/data/db
$ Chown-R mongodb: mongodb/data
Of course, you can use the -- dbpath command to specify that MongoDB stores data in another directory.
Step 3: run the database
In the console:
$ Nohup./mongodb-xxxxxxx/bin/mongod &
$./Mongodb-xxxxxxx/bin/mongo
> Db. foo. save ({a: 1 })
> Db. foo. find ()
The result is:
{"_ Id": ObjectId ("4cd181a31415ffb41a094f43"), "a": 1}
The above three steps are OK !! Such a simple MongoDB database can run smoothly.
  • 1
  • 2
  • Next Page

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.