Chriskuei Keep calm and code on

Install MongoDB on CentOS

Install

Download the binary files

curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.3.tgz

Extract

tar -zxvf mongodb-linux-x86_64-3.6.3.tgz

Create target directory

mkdir -p mongodb
cp -R -n mongodb-linux-x86_64-3.6.3/ mongodb

Modify shell’s rc file

export PATH=<mongodb-install-directory>/bin:$PATH
eg. export PATH=~/mongodb/mongodb-linux-x86_64-3.6.3/bin:$PATH

Run

Create the data directory

mkdir -p ~/mongodb/data/db

Run MongoDB

Specify the path of the data directory

mongod --dbpath ~/mongodb/data/db

Verity

If success, the process will output for the following line:

[initandlisten] waiting for connections on port 27017

Begin using MongoDB

mongo --host 127.0.0.1:27017