我无法在 Linux Mint 上安装 MongoDB。
操作系统:Linux Mint 19.1
内核:Linux 4.15.0-50-generic
架构:x86-64
我跟着官方文档。
导入包管理系统使用的公钥
$ wget -qO - https://www.mongodb.org/static/pgp/server-4.0.asc | sudo apt-key add -
为 MongoDB Ubuntu 18.04 (Bionic) 创建列表文件
$ echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" |
sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
重新加载本地包
$ sudo apt-get update
安装 MongoDB 包
$ sudo apt-get install -y mongodb-org
安装时出现以下错误:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
icoutils libboost-program-options1.65.1 libgoogle-perftools4 libpcrecpp0v5
libtcmalloc-minimal4 libwine-development libwxgtk3.0-gtk3-0v5
libyaml-cpp0.5v5 mongodb-server-core python-wxgtk3.0 python-wxversion
wine64-development
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
The following NEW packages will be installed:
mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell
mongodb-org-tools
0 upgraded, 5 newly installed, 0 to remove and 245 not upgraded.
Need to get 48.3 MB/73.0 MB of archives.
After this operation, 267 MB of additional disk space will be used.
Get:1 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0/multiverse amd64 mongodb-org-shell amd64 4.0.12 [9,865 kB]
Get:2 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0/multiverse amd64 mongodb-org-tools amd64 4.0.12 [38.5 MB]
Get:3 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0/multiverse amd64 mongodb-org amd64 4.0.12 [3,528 B]
Fetched 48.3 MB in 31s (1,553 kB/s)
Selecting previously unselected package mongodb-org-shell.
(Reading database ... 349983 files and directories currently installed.)
Preparing to unpack .../mongodb-org-shell_4.0.12_amd64.deb ...
Unpacking mongodb-org-shell (4.0.12) ...
Preparing to unpack .../mongodb-org-server_4.0.12_amd64.deb ...
Unpacking mongodb-org-server (4.0.12) ...
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-server_4.0.12_amd64.deb (--unpack):
trying to overwrite '/usr/bin/mongod', which is also in package mongodb-server-core 1:3.6.3-0ubuntu1.1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../mongodb-org-mongos_4.0.12_amd64.deb ...
Unpacking mongodb-org-mongos (4.0.12) ...
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-mongos_4.0.12_amd64.deb (--unpack):
trying to overwrite '/usr/bin/mongos', which is also in package mongodb-server-core 1:3.6.3-0ubuntu1.1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Selecting previously unselected package mongodb-org-tools.
Preparing to unpack .../mongodb-org-tools_4.0.12_amd64.deb ...
Unpacking mongodb-org-tools (4.0.12) ...
Selecting previously unselected package mongodb-org.
Preparing to unpack .../mongodb-org_4.0.12_amd64.deb ...
Unpacking mongodb-org (4.0.12) ...
Errors were encountered while processing:
/var/cache/apt/archives/mongodb-org-server_4.0.12_amd64.deb
/var/cache/apt/archives/mongodb-org-mongos_4.0.12_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
尝试启动数据库
$ sudo service mongod start
Failed to start mongod.service: Unit mongod.service not found.
下面的命令给出了同样的错误:
sudo apt-get install -f
无法删除 mongodb-server-core:
$ apt remove mongodb-server-core
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
mongodb-org : Depends: mongodb-org-server but it is not going to be installed
Depends: mongodb-org-mongos but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
答案1
与 mongodb-server-core 有冲突尝试
sudo apt-get purge mongod*
sudo apt-get update
并重新安装
答案2
有同样的问题。我在网上找到的没有任何效果。但最终猜到了一个可行的解决方案。
代替
sudo apt-get purge mongod*
我做到了
sudo apt-get purge mongo*
然后问题就解决了。
答案3
我在 Ubuntu 机器上也遇到同样的问题。
sudo apt-get purge mongod*
sudo apt autoremove
sudo apt-get update && sudo apt-get upgrade
上面的命令有帮助。