在出现以下错误后,我尝试在ubuntu 16.04上使用命令sudo apt-get install -y mongodb-org
安装Mongodb:
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
mongodb-org : Depends: mongodb-org-shell but it is not going to be installed
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: Unable to correct problems, you have held broken packages.
答案 0 :(得分:0)
请参阅https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/上的MongoDB文档,其中说使用他们的软件包而不是Ubuntu APT软件包。
以下是概括使用MongoDB软件包的步骤...
添加APT密钥:
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
添加APT来源列表:
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
更新APT:
sudo apt-get update
安装MongoDB社区软件包:
sudo apt-get install -y mongodb-org
启动服务:
sudo service mongod start
使用mongoshell登录数据库:
mongo
答案 1 :(得分:0)
如果其他人为此问题苦苦挣扎,而其他所有答案都无法解决...
这对我有用:
apt-get install mongodb-org-shell
apt-get install mongodb-org-server
apt-get install mongodb-org-mongos
然后再次
sudo apt-get install -y mongodb-org
详情(运行uname -a)
Linux resta-dev 4.15.0-66-generic #75-Ubuntu SMP Tue Oct 1 05:24:09 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
答案 2 :(得分:0)
选择错误的Ubuntu版本时出现此问题。确保再次检查您运行的是正确的。