1024programmer Mongodb Install MongoDB database and Python driver module under Ubuntu11.04 system

Install MongoDB database and Python driver module under Ubuntu11.04 system

First of all, let me explain that my system is Ubuntu 11.04, a 64-bit system. The following installation may need to be modified according to the system conditions.

1. Download the MongoDb installation package

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

2. Unzip

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

For the convenience of typing commands later, you can also change the name, such as mv mongodb-linux-x86_64-2.0.0.tgz
mongo2

3. Install the Python dependency package

According to the official statement, it is recommended to use pip to install MongoDb’s Python driver, but pip first depends on setuptools, so you have to check whether it is installed first.

If not, you can download and install setuptools or:

$ apt-get install python-setuptools

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

In addition, in the process of installing pip, you may need to install python-dev by the way:

$ 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

Then unzip:

$ tar -xvf pip-1.0.2.tar.gz

Then install:

$ cd pip-1.0.2

$python setup.py install

After installing pip, you can use the command to install pymongo:

5. Install the driver for Python for Mongo

It’s simple:

$ pip install pymongo

Note that pymongo can be updated directly through pip in the future, the command is

$ pip –upgrade pymongo

6. Start the mongo service and connect

First, we create a database storage directory for mongo. www.linuxidc.com defaults to /data/db, so if there is no such directory, you have to use sudo
mkdir /data/db to create;

Of course, if you don’t want to use the default database directory, you can also specify it when starting the mongo service.

The next step is to start the service:

$./mongod –dbpath=/data/db

Note that you first need to 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 separate window:

$./mongo

7. After the above steps are completed, you can start writing scripts with py to operate mongo.

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/install-mongodb-database-and-python-driver-module-under-ubuntu11-04-system/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索