从 ubuntu 卸载 mongoDB

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29554521/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 20:23:19  来源:igfitidea点击:

Uninstall mongoDB from ubuntu

mongodbubunturobo3t

提问by Anita

I have installed MongoDB 3.0.1 following the commands in Install MongoDB Community Edition on Ubuntuon my ubuntu 14.04 64 bit system and I installed Robomongointerface 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. 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.

当我尝试使用 Robomongo 连接 MongoDB 时,出现授权失败的错误。我发现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.

任何帮助,将不胜感激。

回答by alicanozkara

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

这对我有用

回答by Kevin Andrid

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 completely clean up, you might also want to remove the data directory

如果你想彻底清理,你可能还想删除数据目录

/var/lib/mongodb

/var/lib/mongodb

回答by ettanany

In my case mongodbpackages are named mongodb-organd mongodb-org-*

在我的情况下,mongodb包被命名mongodb-orgmongodb-org-*

So when I type sudo apt purge mongothen tab(for auto-completion) I can see all installed packages that start with mongo.

因此,当我输入sudo apt purge mongothen tab(用于自动完成)时,我可以看到所有以mongo.

Another option is to run the following command (which will list all packages that contain mongoin 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/mongodband /var/lib/mongodb

当然,正如@alicanozkara 提到的,您需要手动删除一些目录,例如/var/log/mongodb/var/lib/mongodb

Running the following findcommands:

运行以下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:

您可能还想删除 user 和 group mongodb,为此您需要运行:

sudo userdel -r mongodb
sudo groupdel mongodb

To check whether mongodbuser/group exists or not, try:

要检查mongodb用户/组是否存在,请尝试:

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

回答by Ition

use command with sudo,

使用 sudo 命令,

sudo apt-get autoremove --purge mongodb

OR

或者

sudo apt-get remove mongodb* --purge

It will remove complete mongodb

它将删除完整的mongodb

回答by efkan

Sometimes this works;

有时这有效;

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

回答by techyaura

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

回答by Shyam07

use sudo with the command, sudo apt-get remove --purge mongodb apt-get autoremove --purge mongodb

将 sudo 与命令一起使用, sudo apt-get remove --purge mongodb apt-get autoremove --purge mongodb

回答by Chung Le

To uninstalling existing MongoDB packages. I think this linkwill helpful.

卸载现有的 MongoDB 包。我认为这个链接会有所帮助。