安装MongoDB
1.导入MongoDB中public Key值到Ubuntu包系统中
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
2.在Sources列表中创建MongoDB的文件
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
3.重新加载本地的文件包库列表
sudo apt-get update
4.安装MongoDB数据库
sudo apt-get install -y mongodb-org
5.启动MongoDB
sudo service mongod start
6.关闭MongoDB
sudo service mongod stop
7.重启MongoDB
sudo service mongod restart
8.进入MongoDB
mongo
![](http://static.oschina.net/uploads/space/2016/0716/130159_kmP1_2772739.png)
===================================================
卸载MongoDB
1.关闭MongoDB
sudo service mongod stop
2.删除安装包
sudo apt-get purge mongodb-org*
3.删除数据
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb