How Do You Install MongoDB on a Linux Server?

Problem scenario
You want to install MongoDB on a Linux server.  How do you do this?

Solution
1.  If you know your distribution of Linux, go to step #2.  Otherwise try this command:  cat /etc/*-release

2.  Do one of the following that corresponds to your distribution of Linux:

On Debian:  sudo apt-get -y install mongodb mongodb-server

On Ubuntu 16.x or Ubuntu 17.x run these two commands (that may span three lines):

curl http://repo.mongodb.org/apt/ubuntu/dists/xenial/mongodb-org/3.6/multiverse/binary-amd64/mongodb-org-server_3.6.4_amd64.deb > /tmp/mongodb-org-server_3.6.4_amd64.deb
dpkg -i /tmp/mongodb-org-server_3.6.4_amd64.deb

On CentOS/RHEL/Fedora:  sudo yum -y install mongodb-server

3.  To test:  mongod -version

Leave a comment

Your email address will not be published. Required fields are marked *