一、使用 Ubuntu 仓库安装 MongoDB。
apt install mongodb
简单但不是最新版本的MongoDB
二、使用官方仓库安装 MongoDB。
1. Import the public key used by the package management system.
wget -qO - https://www.mongodb.org/static/pgp/server-3.4.asc | sudo apt-key add -
2. Create a list file for MongoDB.
Ubuntu 14.04
echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
Ubuntu 16.04
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
3. Reload local package database.
apt update
4. Install the MongoDB packages.
apt install -y mongodb-org