一、导入包管理系统使用的公钥
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
二、为MongoDB创建一个列表文件
Ubuntu 12.04
echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
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
@H_301_43@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
三、重新加载本地包数据库
sudo apt-get update
四、安装最新的稳定版本的MongoDB
sudo apt-get install -y mongodb-org
六、启动MongoDB
sudo service mongod stop
八、重启MongoDB
sudo service mongod restart
九、卸载MongoDB
sudo service mongod stop sudo apt-get purge mongodb-org* sudo rm -r /var/log/mongodb sudo rm -r /var/lib/mongodb
十、配置文件
dbpath /var/lib/mongodb logpath /var/log/mongodb config path /etc/mongod.conf参考网站:https://docs.mongodb.com/v3.4/tutorial/install-mongodb-on-ubuntu/