Install the MongoDb and Python drivers in Ubuntu11.04

Source: Internet
Author: User
First of all, my system is Ubuntu11.04, 64-bit, the following installation may need to be modified according to the system situation. 1. Download The MongoDb installation package $ wgethttp: // container

First of all, my system is Ubuntu 11.04, 64-bit, the following installation may need to be modified according to the system situation.

1. Download The MongoDb installation package

$ Wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.0.tgz

2. Extract

$ Tar vzf mongodb-linux-x86_64-2.0.0.tgz

In order to facilitate the subsequent command, you can also change a name, such as mv mongodb-linux-x86_64-2.0.0.tgz mongo2

3. Install the Python dependency package

According to the official statement, pip is recommended to install the Python driver of MongoDb. However, pip depends on setuptools first, so you must check whether the Python driver is installed,

If not, download and install setuptools or:

$ Apt-get install python-setuptools

Note: If you are using python3.0 or a later version, use the corresponding version of setuptools.

In addition, during pip installation, you may need to install python-dev:

$ Apt-get install python-dev

4. Install pip

First download:

$ Wget http://pypi.python.org/packages/source/p/pip/pip-1.0.2.tar.gz#md5=47ec6ff3f6d962696fe08d4c8264ad49

Decompress the package:

$ Tar-xvf pip-1.0.2.tar.gz

Then install:

$ Cd pip-1, 1.0.2

$ Python setup. py install

After pip is installed, run the following command to install pymongo:

5. Install the Python for Mongo driver

Simple:

$ Pip install pymongo

Note: You can directly update pymongo using pip in the future. The command is

$ Pip -- upgrade pymongo

6. Start the mongo service and connect to it

First, we will create a database storage directory for mongo. The default value of www.linuxidc.com is/data/db. If this directory is not available, you must create it using sudo mkdir/data/db;

Of course, if you do not want to use the default database directory, you can specify it when starting the mongo service.

Start the service:

$./Mongod -- dbpath =/data/db

Note that you must first enter the directory where mongod is located (for example, my directory is/data/mongo2/bin/mongod), and then/data/db can be replaced with the directory you want to specify.

Finally, you can connect to the database in another independent window:

$./Mongo

7. After completing the preceding steps, you can use py to write a script to operate mongo.

Python writing can refer to this article: http://www.linuxidc.com/Linux/2011-09/43172.htm

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.