Download
MongoDB offers 32-bit and 64-bit installation packages on the Linux platform, which you can download on the website.
: Http://www.mongodb.org/downloads
Installation
After the download is complete, unzip the ZIP package in the directory you installed.
Create a database directory
MongoDB data is stored in the DB directory in the database directory, but this directory is not created automatically during the installation process, so you need to create the data directory manually and create the DB directory in the data directory.
In the following example we create the data directory under the root directory (/).
Note:/data/db is the default startup database path for MongoDB (--dbpath).
Mkdir-p/data/db
Run MongoDB service on the command line
You can then execute the mongod command to start the MONGDB service by executing the bin directory in the MONGO installation directory on the command line.
Note: If your database directory is not/data/db, you can specify it through--dbpath.
$./mongod2015-09-25t16:39:50.549+0800 I JOURNAL [Initandlisten] JOURNAL dir=/data/db/journal2015-09-25t16 : 39:50.550+0800 I JOURNAL [initandlisten] recover:no JOURNAL files present, no recovery needed2015-09-25t16:39:50.8 69+0800 i JOURNAL [Initandlisten] preallocateisfaster=true 3.162015-09-25t16:39:51.206+0800 i JOURNAL [ Initandlisten] preallocateisfaster=true 3.522015-09-25t16:39:52.775+0800 I JOURNAL [Initandlisten] Preallocateisfaster=true 7.7
MongoDB Background Management Shell
If you need to get into MongoDB background management, you need to first open the bin directory under the MongoDB directory and then execute the MONGO command file.
The MongoDB Shell is an interactive JavaScript shell that comes with MongoDB and is used to manipulate and manage MongoDB.
When you enter MongoDB background, it is linked to the test document (database) by default:
$ cd/usr/local/mongodb/bin$./mongomongodb Shell version:3.0.6connecting to:testwelcome to the MongoDB shell ....
Since it is a JavaScript shell, you can run some simple arithmetic operations:
> 2+24> 3+69
Now let's insert some simple data and retrieve the inserted data:
> DB. W3cschool.insert ({x:10}) Writeresult ({"ninserted": 1}) > db. W3cschool.find () {"_id": ObjectId ("5604FF74A274A611B0C990AA"), "X":}>
The first command is to insert data 8 into the Z field of the W3r Collection (table).
MongoDb Web user interface
MongoDB provides a simple HTTP user interface. If you want to enable this feature, you need to specify the parameter--rest at boot time.
$./mongod--dbpath=/data/db--rest
MongoDB's Web interface access port is 1000 more than the service's port.
If your MongoDB run port uses the default of 27017, you can access the Web user interface at the port number 28017, that is, the address is: http://localhost:28017.
Linux Platform Installation MongoDB