简体   繁体   English

从 ubuntu 卸载 mongoDB

[英]Uninstall mongoDB from ubuntu

I have installed MongoDB 3.0.1 following the commands in Install MongoDB Community Edition on Ubuntu on my ubuntu 14.04 64 bit system and I installed Robomongo interface to use that.我已经在我的 ubuntu 14.04 64 位系统上按照在 Ubuntu安装 MongoDB 社区版中的命令安装了 MongoDB 3.0.1,并且我安装了Robomongo接口来使用它。

When I try to connect MongoDB using Robomongo I get an error that authorization failed.当我尝试使用 Robomongo 连接 MongoDB 时,出现授权失败的错误。 I found Add support for SCRAM-SHA-1 authentication (MongoDB 3.0+) which explains that Robomongo 0.8.5 doesn't support MongoDB 3.0.X fully.我发现Add support for SCRAM-SHA-1 authentication (MongoDB 3.0+)这解释了 Robomongo 0.8.5 不完全支持 MongoDB 3.0.X。

In response, I want to remove MongoDB 3.0.1 and install MongoDB 2.2.作为回应,我想删除 MongoDB 3.0.1 并安装 MongoDB 2.2。

I tried the following commands:我尝试了以下命令:

 apt-get remove --purge mongodb

and also并且

apt-get autoremove --purge mongodb

In both cases I got the following error:在这两种情况下,我都收到以下错误:

" Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?" " 无法打开锁定文件 /var/lib/dpkg/lock - open (13: Permission denied) E: 无法锁定管理目录 (/var/lib/dpkg/),您是 root 吗?

Any help would be appreciated.任何帮助,将不胜感激。

sudo service mongod stop
sudo apt-get purge mongodb-org*
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb

this worked for me这对我有用

In my case mongodb packages are named mongodb-org and mongodb-org-*在我的例子中, mongodb包被命名为mongodb-orgmongodb-org-*

So when I type sudo apt purge mongo then tab (for auto-completion) I can see all installed packages that start with mongo .因此,当我输入sudo apt purge mongo然后输入tab (用于自动完成)时,我可以看到所有以mongo开头的已安装软件包。

Another option is to run the following command (which will list all packages that contain mongo in their names or their descriptions):另一种选择是运行以下命令(它将列出名称或描述中包含mongo所有包):

dpkg -l | grep mongo

In summary, I would do (to purge all packages that start with mongo ):总之,我会做(清除所有以mongo开头的包):

sudo apt purge mongo*

and then (to make sure that no mongo packages are left):然后(以确保没有剩下 mongo 包):

dpkg -l | grep mongo

Of course, as mentioned by @alicanozkara, you will need to manually remove some directories like /var/log/mongodb and /var/lib/mongodb当然,正如@alicanozkara 提到的,您需要手动删除一些目录,如/var/log/mongodb/var/lib/mongodb

Running the following find commands:运行以下find命令:

sudo find /etc/ -name "*mongo*" and sudo find /var/ -name "*mongo*" sudo find /etc/ -name "*mongo*"sudo find /var/ -name "*mongo*"

may also show some files that you may want to remove, like:可能还会显示一些您可能想要删除的文件,例如:

/etc/systemd/system/mongodb.service
/etc/apt/sources.list.d/mongodb-org-3.2.list

and:和:

/var/lib/apt/lists/repo.mongodb.*

You may also want to remove user and group mongodb , to do so you need to run:您可能还想删除用户和组mongodb ,为此您需要运行:

sudo userdel -r mongodb
sudo groupdel mongodb

To check whether mongodb user/group exists or not, try:要检查mongodb用户/组是否存在,请尝试:

cut -d: -f1 /etc/passwd | grep mongo
cut -d: -f1 /etc/group | grep mongo

I suggest the following to make sure everything is uninstalled:我建议执行以下操作以确保卸载所有内容:

sudo apt-get purge mongodb mongodb-clients mongodb-server mongodb-dev

sudo apt-get purge mongodb-10gen

sudo apt-get autoremove

This should also remove your config from这也应该从

 /etc/mongodb.conf.

If you want to clean up completely and you might also want to remove the data directory如果你想彻底清理,你可能还想删除数据目录

/var/lib/mongodb

use command with sudo,使用 sudo 命令,

sudo apt-get autoremove --purge mongodb

OR或者

sudo apt-get remove mongodb* --purge

It will remove complete mongodb它将删除完整的mongodb

Stop MongoDB停止 MongoDB

Stop the mongod process by issuing the following command:通过发出以下命令停止 mongod 进程:

sudo service mongod stop

Remove Packages删除包

Remove any MongoDB packages that you had previously installed.删除您之前安装的所有 MongoDB 包。

sudo apt-get purge mongodb-org*

Remove Data Directories.删除数据目录。

Remove MongoDB databases and log files.删除 MongoDB 数据库和日志文件。

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

Sometimes this works;有时这有效;

sudo apt-get install mongodb-org --fix-missing --fix-broken
sudo apt-get autoremove mongodb-org --fix-missing --fix-broken

use sudo with the command:使用sudo命令:

sudo apt-get remove --purge mongodb  
apt-get autoremove --purge mongodb  

这将完全删除 MongoDB:

sudo apt-get remove mongodb* --purge

To uninstalling existing MongoDB packages.卸载现有的 MongoDB 包。 I think this link will helpful.我认为这个链接会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM