Database 如何安装/更新到Postgres 9.4?

Database 如何安装/更新到Postgres 9.4?,database,postgresql,server,Database,Postgresql,Server,我刚刚安装了Postgres,但它似乎已经安装了9.3,我想从9.4开始 我只是从一台新的Ubuntu 14.04.1机器上安装了postgresql 说你可以做: apt-get install postgresql-9.4 但当我尝试时,我得到: E: Couldn't find any package by regex 'postgresql-9.4 好的,我试着在下面的部分添加PostgreSQL Apt存储库,但也找不到任何内容 9.4还没有在包管理器中吗?我做错了什么吗?中没有

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

我只是从一台新的Ubuntu 14.04.1机器上安装了postgresql

说你可以做:

apt-get install postgresql-9.4
但当我尝试时,我得到:

E: Couldn't find any package by regex 'postgresql-9.4
好的,我试着在下面的部分添加PostgreSQL Apt存储库,但也找不到任何内容


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

中没有postgresql-9.4。它被添加到。它将来可能会被后置


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

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

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

    deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main 黛布http://apt.postgresql.org/pub/repos/apt/ 可靠的pgdg主
  • 导入存储库签名密钥,并更新包列表

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

如果您试图在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回购文件

$ 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

信用证:

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

首先,检查Ubuntu的版本:

lsb_release -sc
sudo apt-get update
sudo apt-get install postgresql-9.4
ubuntu@:~$ su postgres
Password:****
createdb database_name
psql -d database_name
您需要为最新版本添加最新的PostgreSQL存储库,否则它将安装PostgreSQL 9.3。这适用于可靠的版本。

sudo add-apt-repository "deb https://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main"
ubuntu@:~$ sudo passwd postgres
Enter new UNIX password:****
Retype new UNIX password:****
passwd: password updated successfully
sudo service postgresql start
更新并安装PostgreSQL 9.4:

lsb_release -sc
sudo apt-get update
sudo apt-get install postgresql-9.4
ubuntu@:~$ su postgres
Password:****
createdb database_name
psql -d database_name
创建默认postgres超级用户和postgres数据库。您需要为postgres超级用户设置密码。

sudo add-apt-repository "deb https://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main"
ubuntu@:~$ sudo passwd postgres
Enter new UNIX password:****
Retype new UNIX password:****
passwd: password updated successfully
sudo service postgresql start
如果服务未启动,您可以启动PostgreSQL服务。

sudo add-apt-repository "deb https://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main"
ubuntu@:~$ sudo passwd postgres
Enter new UNIX password:****
Retype new UNIX password:****
passwd: password updated successfully
sudo service postgresql start
使用postgres用户连接PostgreSQL server:

lsb_release -sc
sudo apt-get update
sudo apt-get install postgresql-9.4
ubuntu@:~$ su postgres
Password:****
createdb database_name
psql -d database_name
创建示例数据库:

lsb_release -sc
sudo apt-get update
sudo apt-get install postgresql-9.4
ubuntu@:~$ su postgres
Password:****
createdb database_name
psql -d database_name
连接到该数据库:

lsb_release -sc
sudo apt-get update
sudo apt-get install postgresql-9.4
ubuntu@:~$ su postgres
Password:****
createdb database_name
psql -d database_name

按照以下步骤安装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

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

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

安装Postgres

yum install postgres 
(注意:记住postgres用户的密码–以后需要)

设立博士后

启动pgAdmin

连接到本地服务器。使用localhost作为服务器名称,使用postgres作为用户名和密码(安装postgres时使用)。 您需要是root用户才能执行此命令。注意:如果在安装过程中未设置密码(sudo apt get install postgresql),则可以按如下方式设置密码:

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

alter user postgres with password 'postgres';
连接到PostgreSQL

安装PostgreSQL数据库服务器后,默认情况下,它将创建一个角色为“postgres”的用户“postgres”。它还创建了一个名为“postgres”的系统帐户。所以,要连接到postgres服务器,请以用户postgres的身份登录到您的系统并连接数据库

$ sudo su - postgres
$ psql
现在您已登录到PostgreSQL数据库服务器。要检查登录信息,请使用数据库命令提示符中的以下命令

postgres-# \conninfo
postgres-# \q
要从PostgreSQL数据库命令提示符断开连接,只需在下面键入命令并按enter键。它会将您返回到Ubuntu命令提示符

postgres-# \conninfo
postgres-# \q

谢谢@Schwern,我的代号也错了,所以这很有帮助。当时的脚本帮了我。这应该是这个问题的公认答案。因为这是Ubuntu 14.04的正确答案。@mbu\CE另一个也可以。没有必要把其他作者的作品放下。