无法在 Ubuntu 上安装 postgres (E: Unable to locate package postgresql)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/53434849/
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
Cannot install postgres on Ubuntu (E: Unable to locate package postgresql)
提问by Lucas Perry
So I'm having this problem where for some reason I can't install any package on my ubuntu system.
I'm currently on Ubuntu 16.10
.
所以我遇到了这个问题,由于某种原因我无法在我的 ubuntu 系统上安装任何软件包。我目前在Ubuntu 16.10
.
terminal install logs
终端安装日志
Update:
更新:
I've done entered those commands and got this.
我已经输入了这些命令并得到了这个。
after update and apt-cache
更新和 apt-cache 之后
What should I do now?
我现在应该怎么办?
回答by Tarique
sudo apt-get install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/
lsb_release -cs-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
sudo apt-get install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/
lsb_release -cs-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
After installing the PostgreSQL database server, by default, it creates a user ‘postgres' with role ‘postgres'. Also creates a system account with the same name ‘postgres'. So to connect to Postgres server, log in to your system as user postgres and connect database.
安装 PostgreSQL 数据库服务器后,默认情况下,它会创建一个角色为“postgres”的用户“postgres”。还创建一个同名的系统帐户“postgres”。因此,要连接到 Postgres 服务器,请以 postgres 用户身份登录到您的系统并连接数据库。
$ sudo su - postgres
.
$ sudo su - postgres
.
$ psql
$ psql
回答by Maciej Sz
First do
先做
sudo apt-get update
You should get no errors upon updating. In case you do, then you might have issues with your firewall, or something blocking you from updating repositories. Check the output carefully.
更新时应该不会出现错误。如果你这样做了,那么你的防火墙可能有问题,或者阻止你更新存储库的东西。仔细检查输出。
And then search for the correct (exact!) package name using this command:
然后使用以下命令搜索正确的(确切的!)包名称:
apt-cache search postgresql
As a last resort you could add external 3rd Party repository as described in this answer. Just remember to use your distribution name instead of "xenial".
作为最后的手段,您可以添加外部 3rd Party 存储库,如本答案所述。请记住使用您的发行版名称而不是“xenial”。