Installing MongoDB on Ubuntu

To install mongodb on Ubuntu, run

apt install mongodb

To check version of mongodb installed, run

root@backup:~# mongo --version
MongoDB shell version: 2.6.10

Install latest version from

The mongodb provided by your operating system maybe older, to get latest stable version, run

apt-key adv --keyserver hkp:// --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb [ arch=amd64,arm64 ] xenial/mongodb-org/3.4 multiverse" > /etc/apt/sources.list.d/mongodb-org-3.4.list
apt-get update
apt-get install -y mongodb-org

To start mogodb, run

service mongodb start

Ubuntu 16.04

Mongodb won’t start on Ubuntu 16.04

root@backup:~# systemctl start mongodb
Failed to start mongodb.service: Unit mongodb.service is masked.
root@backup:~# cat /lib/systemd/system/mongodb.service
Description=High-performance, schema-free document-oriented database

ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf


You can manually start mongodb with command

/usr/bin/mongod --quiet --config /etc/mongod.conf

You can run it inside screen or tmux.

Posted in Linux