Skip to content

Instantly share code, notes, and snippets.

@sheikhwaqas
Last active September 17, 2020 09:55
Show Gist options
  • Save sheikhwaqas/f2c0301099c293fc2fdccc46bb48186a to your computer and use it in GitHub Desktop.
Save sheikhwaqas/f2c0301099c293fc2fdccc46bb48186a to your computer and use it in GitHub Desktop.
Install mongoDB 3.4 on Ubuntu 16.04 LTS
###############################################################################
# Install mongoDB Server on Ubuntu 16.04 LTS
###############################################################################
# Import the Public Key used by the Ubuntu Package Manager
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
# Create a file list for mongoDB to fetch the current repository
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.4.list
# Update the Ubuntu Packages
apt update
# Install MongoDB
apt install mongodb-org -y
# Change mongoDB Listening IP Address from local 127.0.0.1 to All IPs 0.0.0.0
sed -i 's/127\.0\.0\.1/0\.0\.0\.0/g' /etc/mongod.conf
# Start the MongoDB Service
service mongod start
# End Script
echo "Thanks for using this script."
###############################################################################
@cn0047
Copy link

cn0047 commented Jun 9, 2017

Thank you!

@waynebaylor
Copy link

if you're going to have mongo listening on all ip addresses, then you should also secure it by creating a user and enabling authentication.

also, line #24 refers to MySQL not mongo.

@sivaprakashDesingu
Copy link

sivaprakashDesingu commented Feb 24, 2020

When I was tried the above steps, My system automatically installed with V4.2.5, so I tied the below command which downgraded the version to 3.4.9

sudo apt-get install -y --allow-downgrades mongodb-org=3.4.10 mongodb-org-server=3.4.10 mongodb-org-shell=3.4.10 mongodb-org-mongos=3.4.10 mongodb-org-tools=3.4.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment