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