How does one install the MongoDB database in Linux? Follow these three steps to install MongoDB in Linux.
Read more: Install and start MongoDB in Linux
Step 1: download an object
For 32-bit linux
$ Curl http://downloads.mongodb.org/linux/mongodb-linux-i686-1.4.4.tgz> mongo. tgz
$ Tar xzf mongo. tgz
For 64-bit linux
$ Curl http://downloads.mongodb.org/linux/mongodb-linux-x86_64-1.4.4.tgz> mongo. tgz
$ Tar xzf mongo. tgz
If curl Is Not Installed
Install apt-get install curl first
Step 2: create a data folder
By default, MongoDB stores data in the/data/db/folder, which needs to be manually created.
Create an ECS instance as follows:
$ Adduser mongodb
$ Passwd mongodb
$ Sudo mkdir-p/data/db/
$ Sudo chown 'id-U'/data/db
$ Chown-R mongodb: mongodb/data
Of course, you can use the -- dbpath command to specify that MongoDB stores data in another directory.
Step 3: run the database
In the console:
$ Nohup./mongodb-xxxxxxx/bin/mongod &
$./Mongodb-xxxxxxx/bin/mongo
> Db. foo. save ({a: 1 })
> Db. foo. find ()
The result is:
{"_ Id": ObjectId ("4cd181a31415ffb41a094f43"), "a": 1}
The above three steps are OK !! Such a simple MongoDB database can run smoothly.