HostOnNet Blog

Installing MongoDB on Ubuntu

Looking for Linux Server Admin or WordPress Expert? We can help.

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
root@backup:~# 

Install latest version from Mongodb.com

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

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu 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
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target
root@backup:~# 

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

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.