我正在尝试按照本教程在我的 ubuntu 机器上安装 postgres:
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-14-04
我可以创建新用户,使用 psql 命令。但是当我运行 postgres -v 我得到错误:
当前未安装程序“postgres”。您可以通过键入以下内容来安装它:
sudo apt-get install postgres-xc
前几天我试图检查我是否有 libxml2 但我不得不以另一种方式检查?也许情况与此相同?我不确定...
最佳答案
第 1 步:添加 PostgreSQL Apt 存储库
PostgreSQL 软件包也可以在默认的 Ubuntu 存储库中使用,但是当我尝试在 Ubuntu 12.04 上安装 PostgreSQL 时,我只发现 PostgreSQL 9.1 在默认的 apt 存储库中。因此,我要求您首先使用以下命令在 PostgreSQL 官方网站上建议的系统中添加 PostgreSQL apt 存储库。
$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
$ wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -
第二步:安装 PostgreSQL
现在我们已经在我们的系统中添加了 PostgreSQL 官方存储库,首先我们需要更新存储库列表。之后,使用以下命令在我们的 Ubuntu 系统中安装最新的 PostgreSQL 服务器。
$ sudo apt-get update
$ sudo apt-get install postgresql postgresql-contrib
第 3 步:连接到 PostgreSQL
安装 PostgreSQL 数据库服务器后,默认情况下它会创建一个角色为“postgres”的用户“postgres”。它还创建一个具有相同名称“postgres”的系统帐户。因此,要连接到 postgres 服务器,请以用户 postgres 登录到您的系统并连接数据库。
$ sudo su - postgres
$ psql
现在您已登录到 PostgreSQL 数据库服务器。要检查登录信息,请从数据库命令提示符使用以下命令。
postgres-# \conninfo
要断开与 PostgreSQL 数据库命令提示符的连接,只需键入以下命令并按 Enter。它会让你回到 Ubuntu 命令提示符。
postgres-# \q
关于database - 安装了postegres,但它说没有安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30959072/