Install MongoDB on Linux With Examples

Sometime back I wrote a post on how to install MongoDB on Mac OS X. However most of the development usually happens on Unix/Linux machines. So today we will look into how to install MongoDB on linux system.

Install MongoDB on Linux

Current version of MongoDB is 3.4.7 and I will be installing 64-bit version through command line. The steps to install MongoDB on Linux are very simple, just follow the below terminal commands to download and install it.

    1. Download and extract the MongoDB binaries

    1. Add MongoDB bin directory to PATH variable

    1. Create directory for MongoDB files and start it

    1. Use “ps” command to confirm MongoDB is running

That’s it, our MongoDB is installed on linux machine and running fine.

However, you might want to export the PATH through your user profile i.e .bash_profile or .profile, so that it’s not gone once you quit the terminal.

Execute MongoDB commands

Now let’s connect to the MongoDB and run some mongodb commands to make sure it’s running fine.

As you can see that everything seems to be smooth and I am able to save and retrieve data from MongoDB database.

If you quit the terminal from which the mongodb was started, it will be stopped. Use nohup command to start it, so that it won’t stop even after you close the terminal.

MongoDB Download Page

By admin

Leave a Reply

%d bloggers like this: