MongoDB provides a 64-bit installation package for each Linux distribution, and you can download the installation package on the website. : https://www.mongodb.com/download-center#community
Download the installation package and unzip
tgz(The following shows the installation on a 64-bit Linux).
Curl-o https://fastdl.mongodb.org/linux/mongodb-linux-x86_ 64-3.0.6.tgz # download tar -ZXVF mongodb-linux-x86_64-3.0 6.tgz # unzip MV mongodb-< Span class= "PLN" >linux-x86_64-3.06//usr/local /mongodb # copy the unpacked package to the specified directory
MongoDB's executable file is located in the bin directory, so you can add it to your path path:
Export PATH=<mongodb-Install-directory>/bin:$PATH
<mongodb-install-directory> for your MongoDB installation path. As the /usr/local/mongodb of this article.
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).
-/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+0800I JOURNAL[Initandlisten]Journal Dir=/data/Db/Journal2015-09-25t16:39:50.550+0800I JOURNAL[Initandlisten]Recover: NoJournal Files present, NoRecovery needed2015-09-25t16:39:50.869+0800I JOURNAL[Initandlisten]Preallocateisfaster=True 3.162015-09-25t16:39:51.206+0800 I JOURNAL [initandlisten] preallocateisfaster=true 3.52-25t16: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:
/usr/local/MongoDB/./MONGOmongodb Shell version:3.0. 6connecting to: testWelcomeMongoDB 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.Runoob.Insert({X:10})Writeresult({ "Ninserted" : 1 } ) > Db.. Find () { "_id" : objectid ( "5604FF74A274A611B0C990AA" "x" : 10 }< Span class= "pun" >>
The first command inserts the number 10 into the X field of the Runoob collection.
MongoDb Web user interface
Download Mongodb-compass
Linux Platform Installation MongoDB