Today I will tell you How To Install MongoDB On Linux.
1. We download and unarchive MongoDB packages.
For the installation link, after selecting the version and platform we want to install from the MongoDB download page, we copy the link with the Copy Link option.
1 | https://www.mongodb.com/try/download/community |
1 2 3 4 | $ mkdir mongodb $ cd mongodb $ curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-5.0.4.tgz $ tar -xvf mongodb-linux-x86_64-rhel70-5.0.4.tgz |
2. We add the MongoDB bin directory to the PATH variable.
1 2 3 4 5 | $ mv mongodb-linux-x86_64-rhel70-5.0.4 mongodb $ cd mongodb/ $ echo $PATH /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin $ export PATH=$PATH:/home/mongodb/mongodb/bin |
3. We create the MongoDB data directory and start MongoDB.
1 2 3 | $ mkdir -p /data/db $ cd bin/ $ ./mongod --dbpath /home/mongodb/mongodb/data & |
4. It is learned whether MongoDB is running or not with the following command.
1 2 3 | $ ps -ef | grep mongo root 18127 16200 1 11:03 pts/3 00:00:00 ./mongod --dbpath /home/mongodb/mongodb/data root 18231 17964 0 11:04 pts/4 00:00:00 grep --color=auto mongo |
5. We connect to MongoDB as follows.
1 2 | $ cd /home/mongodb/mongodb/bin/ $ ./mongo |