我正在try 下载mongodb,并遵循这link个步骤.

但当我走到这一步:

sudo apt-get install -y mongodb-org

我得到以下错误:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package mongodb-org  //This is the error

为什么会发生这种情况,是否有解决办法?

推荐答案

我也遇到了同样的问题,但通过更改包文件部分命令来解决.我遵循的整个步骤是:

首先try 使用以下命令:

这是Ubuntu提供的非官方mongodb包,它不是由mongodb维护的,并且与mongodb的官方支持包冲突.

如果上述命令不起作用,则可以通过以下程序之一解决问题:

#Step 1:  Import the MongoDB public key
#In Ubuntu 18.*+, you may get invalid signatures. --recv value may need to be updated to EA312927. 
#See here for more details on the invalid signature issue: [https://stackoverflow.com/questions/34733340/mongodb-gpg-invalid-signatures][1]

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

#Step 2: Generate a file with the MongoDB repository url
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list

#Step 3: Refresh the local database with the packages
sudo apt-get update

#Step 4: Install the last stable MongoDB version and all the necessary packages on our system
sudo apt-get install mongodb-org

         #Or
# The unofficial mongodb package provided by Ubuntu is not maintained by MongoDB and conflict with MongoDB’s offically supported packages. Use the official MongoDB mongodb-org packages, which are kept up-to-date with the most recent major and minor MongoDB releases.
sudo apt-get install -y mongodb 

希望这对你也有用.你可以跟着这个MongoDB

Update

#Step 2: Generate a file with the MongoDB repository url
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list

如果你使用Ubuntu 14.04,那么使用下面的步骤,而不是上面的step 2

#Step 2: Generate a file with the MongoDB repository url
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

Mongodb相关问答推荐

MongoDB-如何过滤和获取数组字段中的最新数据

Mongo 将一个数组链接到另一个数组

随着时间的推移在 mongodb 中获得

根据聚合管道MongoDB Atlas触发器中的条件更新多个字段

将子文档中的所有字段设置为 false,然后在单个查询中将第二个字段设置为 true

Java MongoDB FindOne 获取最后插入的记录

具有最佳插入/秒性能的数据库?

使用 MongoDb 处理迁移

Mongoose 是否真的验证了对象 ID 的存在?

如何获取 Mongoid 文档的所有字段名称?

使用 MongoDB Java 驱动程序将 DBObject 转换为 POJO

java.lang.IncompatibleClassChangeError:Implementing class Mongo

如何使用node.js http服务器从mongodb返回大量行?

MongoException: Index with name: code already exists with different options

Java Mongodb 正则表达式查询

Flask:设置应用程序和请求特定的属性?

填充mongoose后查找

如何向 mongodb 2.6 添加身份验证?

Spring Data MongoDB - 在哪里以编程方式为 Mongo 集合创建索引?

对象不是 JSON 可序列化的