【问题标题】:How do I install/update to Postgres 9.4?如何安装/更新到 Postgres 9.4?
【发布时间】:2015-02-23 11:53:07
【问题描述】:

我刚刚安装了 Postgres,但它似乎已经安装了 9.3,我想从 9.4 开始

我只是在一台新的 Ubuntu 14.04.1 机器上进行了 apt-get install postgresql

http://www.postgresql.org/download/linux/ubuntu/

说你可以做到:

apt-get install postgresql-9.4

但是当我尝试时,我得到:

E: Couldn't find any package by regex 'postgresql-9.4

好的,所以我尝试下面的部分添加 PostgreSQL Apt 存储库,但也找不到任何内容。

9.4 还没有在包管理器中吗?我是不是做错了什么?

【问题讨论】:

    标签: database postgresql server


    【解决方案1】:

    postgresql-9.4 在14.04 "Trusty" 中不可用。它是在14.10 "Utopic" 中添加的。将来可能会被反向移植。

    PostgreSQL Ubuntu Download page 上的指示缺少命令。 Their wiki guide 有正确的程序。在尝试安装之前,您必须运行 apt-get update。这将导致系统读取对源的更改。

    【讨论】:

    【解决方案2】:

    您可以从页面中的说明中添加它

    http://www.postgresql.org/download/linux/ubuntu/

    • 创建文件 /etc/apt/sources.list.d/pgdg.list,并为存储库添加一行

      deb http://apt.postgresql.org/pub/repos/apt/trusty-pgdg main
    • 导入存储库签名密钥,并更新软件包列表

      wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key 添加 - sudo apt-get update && sudo apt-get install postgresql-9.4

    【讨论】:

      【解决方案3】:

      如果您尝试在 Ubuntu 14.04 "Trusty" 上安装,您可以按照以下步骤操作:

      检查您的版本:

      $ lsb_release -a
      
      No LSB modules are available.
      Distributor ID: Ubuntu
      Description:    Ubuntu 14.04.3 LTS
      Release:    14.04
      Codename:   trusty
      

      1) 为 postgres 创建新的 apt repo 文件

      $ echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" > /etc/apt/sources.list.d/pgdg.list
      

      2) 导入存储库签名密钥和更新包列表

      $ sudo wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
      $ sudo apt-get update
      

      3) 安装 Postgres

      $ sudo apt-get install postgresql-9.4
      

      信用:http://ubuntuhandbook.org/index.php/2014/02/install-postgresql-ubuntu-14-04/

      【讨论】:

        【解决方案4】:

        以下是在 Ubuntu 14.04 上安装 PostgreSQL 9.4 的步骤。

        Reference taken from this Article:

        首先,检查 Ubuntu 的版本:

        lsb_release -sc
        

        您需要为最新版本添加最新的 PostgreSQL 存储库,否则它将安装 PostgreSQL 9.3。这是可信赖的版本。

        sudo add-apt-repository "deb https://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main"
        

        更新和安装 PostgreSQL 9.4:

        sudo apt-get update
        sudo apt-get install postgresql-9.4
        

        创建默认的 postgres 超级用户和 postgres 数据库。您需要为 postgres 超级用户设置密码。

        ubuntu@:~$ sudo passwd postgres
        Enter new UNIX password:****
        Retype new UNIX password:****
        passwd: password updated successfully
        

        如果服务没有启动,可以启动PostgreSQL服务。

        sudo service postgresql start
        

        使用 postgres 用户连接 PostgreSQL 服务器:

        ubuntu@:~$ su postgres
        Password:****
        

        创建示例数据库:

        createdb database_name
        

        连接到该数据库:

        psql -d database_name
        

        【讨论】:

          【解决方案5】:

          按照以下步骤安装 postgresql。打开终端(Ctrl + Alt + t),然后记下以下命令行

          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 -
          
          
          sudo apt-get update
          sudo apt-get install postgresql-9.6
          

          如果 postgresql 安装成功,那么它会在写完这个命令后返回这个

          psql --version
          psql (PostgreSQL) 9.6.3
          

          【讨论】:

            【解决方案6】:

            PostgreSQL 是一个开源的对象关系数据库系统。它是用于生产服务器的领先数据库服务器之一。 PostgreSQL 允许我们用各种编程语言执行存储过程,如 PHP、C/C++、Python、Java、Perl、Ruby 以及它自己的 PL/pgSQL,类似于 Oracle 的 PL/SQL。

            Postgres 数据库用于数据的持久存储

            安装 Postgres

            yum install postgres 
            

            (注意:记住 postgres 用户的密码——你以后需要它)

            sudo apt-get update
            sudo apt-get upgrade
            sudo apt-get install postgresql-9.6
            

            设置 Postgres

            启动 pgAdmin。

            连接到本地服务器。使用 localhost 作为服务器名称,使用 postgres 作为用户名和安装 Postgres 时使用的密码。 执行此命令需要root用户。注意:如果安装时没有设置密码(sudo apt-get install postgresql),则可以如下设置:

            sudo -u postgres psql postgres
            

            在 postgres 客户端提示符下,使用以下命令设置密码。

            alter user postgres with password 'postgres';
            

            连接到 PostgreSQL

            安装 PostgreSQL 数据库服务器后,默认情况下,它会创建一个角色为“postgres”的用户“postgres”。它还创建一个具有相同名称“postgres”的系统帐户。因此,要连接到 postgres 服务器,请以用户 postgres 登录到您的系统并连接数据库。

            $ sudo su - postgres
            $ psql
            

            现在您已登录到 PostgreSQL 数据库服务器。要检查登录信息,请从数据库命令提示符使用以下命令。

            postgres-# \conninfo
            

            要断开与 PostgreSQL 数据库命令提示符的连接,只需键入以下命令并按 Enter。它会让你回到 Ubuntu 命令提示符。

            postgres-# \q
            

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2014-12-29
              • 1970-01-01
              • 2017-05-30
              • 2014-04-06
              • 2011-04-28
              • 1970-01-01
              相关资源
              最近更新 更多