Ubuntu下Mongodb的卸载

在终端输入以下命令查看MongoDB版本

sun@iZwz99xibtof6c8lod50rhZ:~$ mongo -version
MongoDB shell version: 2.4.9

如果想要安装特定版本使用以下命令:

$ sudo apt-get install -y mongodb-org=版本号 
$ sudo apt-get install -y mongodb-org-server=3.2.9
$ sudo apt-get install -y mongodb-org-shell=版本号
$ sudo apt-get install -y mongodb-org-tools=版本号

MongoDB卸载

一、先停止运行mongodb

sun@iZwz99xibtof6c8lod50rhZ:~$ sudo service mongodb stop
[sudo] password for sun:
mongodb stop/waiting

二、再卸载MongoDB

命令如下:

sudo apt-get purge mongodb

下面是我本地卸载mongodb

sun@iZwz99xibtof6c8lod50rhZ:~$ sudo apt-get purge mongodb
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  amd64-microcode libboost-dev libboost-filesystem1.54.0
  libboost-program-options1.54.0 libboost-system1.54.0 libboost-thread1.54.0
  libboost1.54-dev libgoogle-perftools4 libpcrecpp0 libsnappy1
  libtcmalloc-minimal4 libunwind8 libv8-3.14.5
  linux-image-extra-4.4.0-31-generic mongodb-clients mongodb-dev
  mongodb-server
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  mongodb*
0 upgraded, 0 newly installed, 1 to remove and 72 not upgraded.
After this operation, 43.0 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 148332 files and directories currently installed.)
Removing mongodb (1:2.4.9-1ubuntu2) ...
sun@iZwz99xibtof6c8lod50rhZ:~$                        

三、删除数据库和日志文件

$ sudo rm -r /var/log/mongodb
$ sudo rm -r /var/lib/mongodb

Leave a comment

您的邮箱地址不会被公开。 必填项已用 * 标注