1. Download:
Mongodb.org/download
2. Compress the downloaded compressed file to/usr/lib
3. Create a soft link
Ln-s/usr/lib/mongodb-linux-i686-2.6.7/bin/mongod/usr/bin/mongodln-s/usr/lib/mongodb-linux-i686-2.6.7/bin/mongo /usr/bin/mongo
This allows the Mongod and MONGO instructions to be lowered at the command line.
Of course, it can be installed by Apt-get install Mongodb-server, but the version may be a bit older.
---The following optional----
4. Start the default service
Mongod--dbpath/usr/lib/mongodb-linux-8686-2.6.7/db
But this is not running in the background, it needs to be run in the background.
What should we do about it?
Solution: Create a script Mongod under/ETC/INIT.D and delete the/usr/bin/mongod. As follows:
#!/bin/shservice mongodb-server Start
Set as startup item at the same time:
UPDATE-RC.D Mongod Defaults
Create a new script file/etc/init.d/mongodb-server and set permissions as follows:
#!/bin/shdaemon=/usr/bin/mongodb-linux-i686-2.6.7/bin/mongoddaemon_opts= "--dbpath/usr/lib/ mongodb-linux-i686-2.6.7/db "name=mongodb-serverdesc=mongodb-serverpidfile=/var/run/$NAME. PidUSER = tommycase" ${1 } "in case start" echo "Starting ${desc}:" start-stop-daemon--start--quiet--pidfile ${pidfile} -- Chuid $ (USER}--background--make-pidfile --exec ${deamon}--${deamon_opts} echo "[OK]" ;; Case stop) echo "Stopping ${desc}:" start-stop-daemon--stop--quiet--pidfile ${pidfile} --oknodo echo "[OK]" ;; Esacexit 0
Need to create Pidfile, and set permissions, process slightly.
The above configuration, each boot, automatically start MongoDB default service, database for/usr/lib/mongodb-...../db
You can simply type MONGO at the command line to connect to the default db.
----Split--------------
The following development-related:
(such as the case of Mongoengine)
From Mongoengin import *connect (' local ') class Test (Document): name = Stringfield (max_length=100) # ...
Ubuntu under MongoDB Installation